Google Ads Pixel not tracking any conversion after migration

gs_thelos999
Visitor
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.

Reply 1 (1)
weotch
Shopify Partner
24 0 6