Hello,
I have couple of questions about the how the Shopify Custom Pixels interact with the pixels on the theme layout file.
-
If I have added a Google Adwords pixel on the theme layout file and then added the Adwords Conversion code in the Custom pixels for the checkout_completed to fire a purchase event for Google, will it still work or do I need to put everything under webpixel.
-
If I have add the a script in the custom webpixel without any event checking, will it fire on all the pages ( equivivalent to page_view) and then add the customer conversion code under if statement for checkout_comleted that will only fire if the order status is checkout_completed. Is that a good practice?
// Load the Google Adwords script asynchronously
(function() {
var gtagScript = document.createElement('script');
gtagScript.async = true;
gtagScript.src='https://www.googletagmanager.com/gtag/js?id=AW-XXX';
document.head.appendChild(gtagScript);
})();
// Initialize the dataLayer and gtag function
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
// Execute the gtag function to set up Google Analytics
gtag('js', new Date());
gtag('config', 'AW-XXX');
//Checkout Completed code
analytics.subscribe("checkout_completed", (event) => {
gtag('event', 'conversion', {
'send_to': 'AW-XXX/YYY',
'value': event.data.checkout.totalPrice.amount,
'currency': event.data.checkout. currencyCode',
'transaction_id': event.data.checkout.order_number,
});
})