Hi,
Currently the only way is to use the customer* variables in the data layer on the order received page:
customerBillingFirstName
customerBillingLastName
customerBillingPostcode
customerBillingCountry
customerBillingEmail
Using this, you need to build the required JS code using a custom JS variable on the GTM UI
Google’s Tag Technical Solutions Team at Google Operations Center in India gave me this script which they said needs to go on the order received page:
<script>
dataLayer.push({
'enhanced_conversion_data': {
"email": 'customerBillingEmail',
"phone_number": 'customerBillingPhone'
}
});
</script>
Is that correct?
Also, how do I build the required JS code using a custom JS variable on the GTM UI?
Sorry for any confusion, I’m not a developer… Google’s marketing material said Google Tag Manager didn’t require a developer!
Hi,
GTM itself can help you to move on with lots of tasks without the need for a developer, that is true. However the there are some advanced cases like this where unfortunately some coding is required indeed.
Steps that do not need coding:
#1 Create two new variables in your GTM container with the type Data Layer Variable and enter this into the variable name field for in the first case: customerBillingEmail then this in the second case: customerBillingPhone
I assume you use the same name for the GTM variable as the data layer variable name.
Then, you need to create a 3rd GTM variable, this time with the type Custom JavaScript variable and enter this code:
`function () {
return {
“email”: {{customerBillingEmail}},
“phone_number”: {{customerBillingPhone}}
}
}
Select this 3rd variable in your Google Ads conversion tag while setting up user provided data.
Hi Thomas,
Thanks for the reply.
Is your code for the Custom JavaScript variable definitely correct as GTM errors saying invalid JavaScript found?
Many thanks in advance,
Hi @duracelltomi!
Why do you suggest to crate a custom javascript variable instead of just using these 2 variables (customerBillingEmail and customerBillingPhone) directly on the user provided data tags?
Thanks for clarifying!
-
This reply was modified 4 years, 1 month ago by
djwilko12.
Hi @duracelltomi,
When I add that code, I am getting this error
“Error at line 3, character 1: Parse error. Character ‘“’ (U+201C) is not a valid identifier start char”
I am not sure what is wrong. At the same time, I don’t understand if after that this 3rd variable I should use at the same time on the Email Customer field and Phone field on conversion setup.
Thank you,
Thank you Thomas for these explanations.
I have created the customerBillingEmail and customerBillingPhone variables however I see that they are not populated as part of the Data Layer (ss) even though I tried both Version 1 and 2.
As im-diamond.com we are using the latest versions of WP, WC, GTM4WP and Neve theme, might this be related to the theme somehow? (The email address is shown in the order-received page, ss) If not then would you have any pointers why we might be having the issue?