SEO, AdWords, affiliates, advertising, and promotions
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.
This is also reported here: https://community.shopify.com/c/shopify-discussions/shopify-custom-pixel-is-incompatible-with-google...
User | RANK |
---|---|
9 | |
7 | |
6 | |
5 | |
4 |
Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023