Videos
Can you use Google Analytics on Shopify?
How do you connect Google Analytics to Shopify?
How to setup Google Analytics 4 for Shopify?
Insert the GA4 tracking script with your Measurement ID in the section of your theme’s code.
Alternatively, you can use Google Tag Manager to manage your GA4 tags efficiently.
Shopify's Checkout Extensibility isn't mandatory until August 2025 but you can get your Google Ads conversion tracking set up now. I had a meeting with the Google Tag Team because I had a client prematurely upgrade their account and didn't tell me, severing the purchase conversion action that is the primary optimization source for the account.
Below is the code they gave me to replace it, insert it in Shopify under Settings > Customer Events. Create a custom pixel, swap out CONVERSIONID (leave the AW- prefix) and CONVERSIONLABEL in the code below with the data for your conversion action. When you're done, hit "save" in the top right corner, then click "connect." Also make sure to remove the previous conversion tracking code under Checkout > Additional Scripts if that's what you're currently using.
This is only set up to fire on a purchase completion, but it works for me and passes dynamic revenue + enhanced conversion parameters.
//gtag starts here
const script = document.createElement('script');
script.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=AW-CONVERSIONID');
script.setAttribute('async', '');
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-CONVERSIONID');
//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-CONVERSIONID/CONVERSIONLABEL',
'value': event.data.checkout.totalPrice.amount,
'transaction_id': event.data.checkout.order.id,
'currency': event.data.checkout.currencyCode
});
});