Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wurwal/9b6bd12affb57108fec1338b5c2c5b25 to your computer and use it in GitHub Desktop.
Save wurwal/9b6bd12affb57108fec1338b5c2c5b25 to your computer and use it in GitHub Desktop.
add to thank you page
<script>
jQuery(document).ready(function() {
// Function to retrieve cookie value by name
function getCookie(name) {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
// Check if this cookie is the one we are looking for
if (cookie.indexOf(name + '=') === 0) {
// Return the cookie value
return cookie.substring(name.length + 1);
}
}
// Return null if cookie not found
return null;
}
// Retrieve the value of the cookie
var ec_email_cookie = getCookie('ec_email_cf');
console.log(ec_email_cookie); // Check the value in the console
dataLayer.push({
'event':'ec_formsubmit',
'enhanced_conversion_data': {
"email": ec_email_cookie
}
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment