Re: Google Ads Pixel not tracking any conversion after migration

Google Ads Pixel not tracking any conversion after migration

gs_thelos999
Shopify Partner
1 0 1

We've recently upgraded to checkout extensibility and with this certain scripts had to be migrated to customer event Pixels - Google Ads being one of them. It seems like it is no longer tracking conversion on our site. Here is was we have for our pixel:

 

// Google Ads
const gaScript = document.createElement('script');
gaScript.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXXX');
gaScript.setAttribute('async', '');
document.head.appendChild(gaScript);

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-XXXXXXXXX');
gtag('config', 'DC-XXXXXXX');

// Page View Conversion Event
analytics.subscribe("page_viewed", (event) => {
  if (!event.context.window.location.pathname.includes('checkouts')){
    let pathname = event.context.window.location.pathname;
    let p = '';
    if ( pathname == '/' ){
      p = 'Home';
    } else if ( pathname.includes('collections') ){
      p = 'Category'
    } else if ( pathname.includes('products') ){
      p = 'Product'
    } else if (pathname.includes('search')) {
      p = 'Search'
    } else {
      p = 'Other'
    }

    gtag('event', 'conversion', {
      'allow_custom_scripts': true,
      'u1': `${p}`,      
      'u3': `${event.context.window.location.href}`,
      'send_to': 'DC-XXXXXXX/cmrtg/grunt0+standard'
    });
  }
});


// PDP Conversion Event
analytics.subscribe("product_viewed", (event) => {
  gtag('event', 'conversion', {
    'allow_custom_scripts': true,
    'u4': `${event.data.productVariant.id}`,  // Product ID
    'send_to': 'DC-XXXXXXX/cmrtg/grunt0+standard'
  });
})

// Collection Conversion Event
analytics.subscribe("collection_viewed", (event) => {
  gtag('event', 'conversion', {
    'allow_custom_scripts': true,
    'u2': `${event.data.collection.title}`,  // Product ID
    'send_to': 'DC-XXXXXXX/cmrtg/grunt0+standard'
  });
})

// Purchase Conversion Event
analytics.subscribe("checkout_completed", (event) => {
  let customerStatus = ( init.data.customer ? 'customer' : 'guest' )
  let productIds = event.data.checkout.lineItems.map((item) => item.variant.id)
  gtag('event', 'conversion', {
      'send_to': 'AW-976169126/vqNPCN-hltcBEKbRvNED',
      'value': `${event.data.checkout.totalPrice.amount}`,
      'currency': `${event.data.checkout.currencyCode}`,
      'transaction_id': `${event.data.checkout.order.id}`
  });
  gtag('event', 'purchase', {
    'allow_custom_scripts': true,
    'value': `${event.data.checkout.totalPrice.amount}`,
    'transaction_id': `${event.data.checkout.order.id}`,
    'u1': 'purchase',    
    'u2': 'checkout',
    'u3': `${event.context.document.location.href}`,
    'u4': productIds,
    'u5': `${customerStatus}`,
    'u6': `${event.data.checkout.order.id}`,
    'u7': `${event.data.checkout.currencyCode}`,
    'u8': `${event.data.checkout.totalPrice.amount}`,
    'u10': `${init.data.customer?.ordersCount ? init.data.customer.ordersCount : 0}`,
    'send_to': 'DC-XXXXXXX/cmconv/grunt0+transactions'
  });
});

 

Going back and forth between this and the legacy scripts, we can't see anything that would affect conversion tracking. Any suggestion on this would be greatly appreciated.

Replies 5 (5)

weotch
Shopify Partner
24 0 12

Himalcp
Shopify Partner
3 0 1

Here you can see i can track successfully after adding such things.

//gtag starts here
const script = document.createElement('script');
script.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=101071143813');
script.setAttribute('async', '');
document.head.appendChild(script);

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '101071143813');
//gtag ends here

//ec + purchase code starts here

analytics.subscribe("checkout_completed", (event) => {
gtag('set', 'user_data', {
"email": event.data.checkout.email,
"phone_number": event.data.checkout.phone
});
gtag('event', 'conversion', {
'send_to': 'AW-101071143813/sGKmCLmavwUQhbfh_gM',
'value': event.data.checkout.totalPrice.amount,
'transaction_id': event.data.checkout.order.id,
'currency': event.data.checkout.currencyCode
});
});
// P.C. end


//Enhanced conversion
window.dataLayer = window.dataLayer || [];
var enhanced_conversion_data = {
'first_name': '{{ checkout.billing_address.first_name }}',
'last_name': '{{ checkout.billing_address.last_name }}',
'home_address': {
'street': '{{ checkout.billing_address.street }}',
'city': '{{ checkout.billing_address.city }}',
'region': '{{ checkout.billing_address.province }}',
'postal_code': '{{ checkout.billing_address.zip }}',
'country': '{{ checkout.billing_address.country_code }}'
}
};

if (checkout.email){
enhanced_conversion_data.email = '{{ checkout.email }}';
}

if (checkout.billing_address.phone){
enhanced_conversion_data.phone_number = '{{ checkout.billing_address.phone }}';
}

window.dataLayer.push({
'event': 'checkout',
'ecommerce': {
'currencyCode': '{{ shop.currency }}',
'purchase': {
'actionField': {
'id': '{{ order.order_number }}',
'affiliation': '{{ shop.name }}'
},
'products': [
// {% for line_item in order.line_items %}
{
'id': '{{ line_item.variant.sku }}',
'name': '{{ line_item.title }}',
'price': '{{ line_item.price | money_without_currency }}',
'quantity': '{{ line_item.quantity }}'
}
// {% unless forloop.last %},{% endunless %}
// {% endfor %}
]
}
},
'enhanced_conversion_data': enhanced_conversion_data
});

// E.C. end


window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'checkout',
'google_ads_conversion': {
'send_to': 'AW-101071143813',
'value': '{{ checkout.subtotal_price | money_without_currency }}',
'currency': '{{ shop.currency }}',
'transaction_id': '{{ order.order_number }}'
}
});


window.dataLayer = window.dataLayer || [];
var id = [];

//loop issue...
// {% for line_item in order.line_items %}
// id.push('{{ line_item.variant.sku }}');
//{% endfor %}

window.dataLayer.push({
'event': 'checkout',
'ecommerce': {
'currencyCode': '{{ shop.currency }}',
'purchase': {
'actionField': {
'id': '{{ order.order_number }}',
'affiliation': '{{ shop.name }}',
'products': id.map(function(sku) {
return {'id': sku, 'name': '', 'price': '', 'quantity': 1};
})
}
}
}
});

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'checkout',
'ecommerce': {
'currencyCode': '{{ shop.currency }}',
'purchase': {
'actionField': {
'id': '{{ order.order_number }}',
'affiliation': '{{ shop.name }}'
},
'products': [
// {% for line_item in order.line_items %}
{
'id': '{{ line_item.variant.sku }}',
'name': '{{ line_item.title }}',
'price': '{{ line_item.price | money_without_currency }}',
'quantity': '{{ line_item.quantity }}'
}
// {% unless forloop.last %},{% endunless %}
// {% endfor %}
]
}
}
});

 

 

Andy-Envision
Shopify Partner
17 0 22

Thanks for posting this, I'm trying to figure out this same thing at the moment. In GTM do you have all these variables set up and the Google Ads Conversion Tracking and Conversion Linker tags set up as well? Or do you not need those because you have the code built into your Pixel code? Thanks!

Himalcp
Shopify Partner
3 0 1

Yeah our marketing team can track everything they need you just have to place AW id of yours.

Thanks

 

Nimra007
Shopify Partner
31 0 0

Hi,

I hope this message finds you well. I am writing to suggest the integration of the Infinite Google Ads Conversion Tracking application into our Shopify store. This application offers several key benefits that can significantly enhance our online marketing efforts and overall business performance.

1. Accurate Conversion Data
2. Improved ROI
3. Enhanced Customer Insights
4. Streamlined Setup
5. GA4 and UET integration
6. Enhanced conversion tracking

7. Compatible with shopify checkout extensibility

 

I have personally used the Infinite Google Ads Conversion Tracking application in previous projects, and I have seen firsthand the positive impact it can have on a business. The accuracy of the conversion data allowed us to refine our ad campaigns effectively, leading to a noticeable increase in conversions and a significant improvement in our marketing ROI. Additionally, the detailed analytics provided by the application helped us understand our customers better and tailor our marketing strategies accordingly.

I believe integrating this application into our Shopify store will bring similar benefits and contribute to our continued growth and success. I am confident that our team will find the application to be a valuable tool in optimizing our marketing efforts.

Thank you for considering this suggestion. I am happy to discuss this further and assist with the integration process if needed.

Best regards,

Nimra