event.data.checkout.email does not have value

Charuhas
Visitor
3 0 0

Hi All, 

 

I am trying to send User data for google ads enhanced conversion pixel on successful purchases. I have tried following code inside the customer events but upon validating the pixel the email is not getting passed.

 

Anyone has any solution for this ? 

 

 

 

 

 

 

 

 

analytics.subscribe("checkout_completed", (event) => {
gtag('event', 'conversion', {
      'send_to': 'xxxxxxxxxxxxxxxxxx',
      'value': event.data.checkout.totalPrice.amount,
      'currency':  event.data.checkout.currencyCode,
      'transaction_id': event.data.checkout.order.id
  });

  gtag('set', 'user_data', {
  "email": event.data.checkout.email,
"phone_number": event.data.checkout.phone,
    "address": {
"first_name": event.data.checkout.shippingAddress.firstName,
"last_name": event.data.checkout.shippingAddress.lastName,
"city":event.data.checkout.shippingAddress.city,
"postal_code": event.data.checkout.shippingAddress.zip,
"country": event.data.checkout.shippingAddress.country
}
});
});

 

 

 

 

 

 

 

 

Replies 3 (3)

DevDynamo
Shopify Partner
42 11 10

Hey @Charuhas ,

 

Did you add the Google Ads base code and enable the enhanced conversion tracking site-wide?

 

Thank You.

- Helpful response? Please give it a Thumbs Up!
- Solved your query? Mark it as an Accepted Solution!
- Level up your Shopify game - Subscribe to 'Shopify Insight' for exclusive insights today!
Charuhas
Visitor
3 0 0

Hello, 

 

Thank you for the message. Yes I have set the google ads base code and conversion as below. Let me know incase if anything flags out to you.

analytics.subscribe('page_viewed', (event) => {
// Load gtag.js script.
const script = document.createElement('script');
script.setAttribute('src','https://www.googletagmanager.com/gtag/js?id=AW-111111111');
script.setAttribute('async', '');
document.head.appendChild(script);

// Configure gtag.js script.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-11111111',{'allow_enhanced_conversions':true });
 });

 

Thank you !

Charuhas

DevDynamo
Shopify Partner
42 11 10

Hey @Charuhas ,

 

Could you please share the website URL so that I can further look into the implementation and provide you with detailed feedback?

 

Thank You.

- Helpful response? Please give it a Thumbs Up!
- Solved your query? Mark it as an Accepted Solution!
- Level up your Shopify game - Subscribe to 'Shopify Insight' for exclusive insights today!