Add Google Ads conversion tracking to Shopify quickly. Choose from three versions:
- Additional Scripts: Deprecated but still installable.
- Shopify Pixel: Direct installation with Google Ads, excluding enhanced conversions.
- Shopify Pixel with Enhanced Conversion & Micro Conversions + GA4: Available when installing via Google Tag Manager.
The Shopify Pixel Code is compatible with Shopify checkout extensibility.
Please note that users checking the code with Tag Assistant or developer tools will not be able to see the code, as Shopify pixels run in sandbox mode, which is not viewable.
Please also note that if you are installing this with Google Analtyics 4, that you will not be able to view the debug mode in GA4. But you can view the realtime data to verify it’s tracking.
Enhanced conversions will be reflected in the status details within a week, depending on your sales volume.
Shopify Pixel + Enhanced Tracking + Micro Conversions + GA4
If you have multiple Google Merchant Center accounts and or you have different feeds, contact us for custom coding. You may also contact us for any other custom coding.
What is New?
- V1.05+ now supports cart data, for using cost of goods based bidding strategy in Google Ads
- V1.07+ now supports micro conversions + bug fixes
- V1.08+ now supports Google Analtyics 4 (optional)
What is the difference between Micro and Macro Conversions?
When it comes to advertising, we have two types of conversions. Macro and Micro conversions. Macro conversions are the website’s primary conversions, such as completing an order or submitting a lead form. Micro conversions are smaller actions such as add to cart, view cart, add a delivery address, etc.
Requirements
You need access to the following accounts.
- Google Tag Manager
- Google Ads
- Google Analytics 4
- Shopify (Customer Events)
Let’s get started!
If you have not yet created a Google Tag Manager account, create one now.
Once the account is created, you should see a popup with your GTM tag, if you don’t see this, don’t worry, simply go to Admin > Install Google Tag Manager
Copy the tag id without GTM- as highlighted in the image below
Replace the following values in the settings:
- GOOGLE_TAG_MANAGER_ID
- Add your GTM tag ID
- GOOGLE_MERCHANT_CENTER_ID
- Add your Google Merchant Center account ID
- PRODUCT_COUNTRY_CODE
- Set your default country ISO2 code, for usage in product IDs
- ESTIMATED_SHIPPING_TIME
- Add your estimated shipping time
- GRANT_CONSENT
- Defaulted to false, if you set it to true, you are forcing to set consent_mode v2 to true, regardless what the use selected (not recommended)
- ID_TYPE
- Set your Google Merchant Center product ID format
- CAPITALIZE_SKU
- If you are not using the default Shopify IDs and you are using SKUs, you can choose to uppercase the value
In the code below replace GTM-123456 with your GTM tag ID
// Code Created By FeedArmy V1.0813 (please don't remove the creator)
// Copyright FeedArmy Co., Ltd.
const GOOGLE_TAG_MANAGER_ID = 'GTM-123456';
const GOOGLE_MERCHANT_CENTER_ID = '123456789';
const PRODUCT_COUNTRY_CODE = 'US';
const ESTIMATED_SHIPPING_TIME = 5;
const GRANT_CONSENT = false; // Use false or true
// for the ID_TYPE, if your products look like shopify_US_123456789_123456798 add the word shopify
// if your products are sku's add the value sku -- const ID_TYPE = 'sku';
// if your proudcts use the variant id use the value variant_id -- const ID_TYPE = 'variant_id';
// if your proudcts use the parent id use the value parent_id -- const ID_TYPE = 'parent_id';
const ID_TYPE = 'shopify';
// If you want to capitalize the SKU set CAPITALIZE_SKU to true, if you don't want to change anything set to false
const CAPITALIZE_SKU = false;
// SETTINGS END
// SETTINGS END
// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
//Initialize GTM tag
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer', GOOGLE_TAG_MANAGER_ID);
if (GRANT_CONSENT === true){
//Google Consent Mode v2
gtag('consent', 'update', {
'ad_storage': 'granted',
'analytics_storage': 'granted',
'ad_user_data': 'granted',
'ad_personalization': 'granted',
});
}
const createLineItemsData = (lineItems, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU) => {
return lineItems.map((item) => {
let itemId;
if (ID_TYPE === "shopify") {
itemId = "shopify_" + PRODUCT_COUNTRY_CODE + "_" + item.variant?.product?.id + "_" + item.variant?.id;
} else if (ID_TYPE === "parent_id") {
itemId = item.variant?.product?.id;
} else if (ID_TYPE === "sku") {
itemId = item.variant?.sku;
if (CAPITALIZE_SKU) {
itemId = itemId.toUpperCase();
}
} else {
itemId = item.variant?.id;
}
// check for discount
let discount = item.discountAllocations?.reduce((total, discountAllocation) => {
return total + parseFloat(discountAllocation.amount.amount);
}, 0) || 0;
// calculate price
let price = parseFloat(item.variant?.price?.amount) - discount;
return {
id: itemId,
item_name: item.variant?.product?.title,
price: price,
quantity: item.quantity
};
});
};
const createLineItemsDataCart = (lineItems, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU) => {
return lineItems.map((item) => {
let itemId;
if (ID_TYPE === "shopify") {
itemId = "shopify_" + PRODUCT_COUNTRY_CODE + "_" + item.merchandise?.id + "_" + item.merchandise?.product?.id;
} else if (ID_TYPE === "parent_id") {
itemId = item.merchandise?.id;
} else if (ID_TYPE === "sku") {
itemId = item.merchandise?.sku;
if (CAPITALIZE_SKU) {
itemId = itemId.toUpperCase();
}
} else {
itemId = item.merchandise?.product?.id;
}
return {
id: itemId,
item_name: item.merchandise?.product?.title,
price: item.cost?.totalAmount?.amount,
quantity: item.quantity
};
});
};
const createLineItemsDataAddToCart = (item, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU) => {
let itemId;
if (ID_TYPE === "shopify") {
itemId = "shopify_" + PRODUCT_COUNTRY_CODE + "_" + item.merchandise?.id + "_" + item.merchandise?.product?.id;
} else if (ID_TYPE === "parent_id") {
itemId = item.merchandise?.id;
} else if (ID_TYPE === "sku") {
itemId = item.merchandise?.sku;
if (CAPITALIZE_SKU) {
itemId = itemId.toUpperCase();
}
} else {
itemId = item.merchandise?.product?.id;
}
return {
id: itemId,
item_name: item.merchandise?.product?.title,
price: item.cost?.totalAmount?.amount,
quantity: item.quantity
};
};
const createLineItemsDataProductView = (item, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU) => {
let itemId;
if (ID_TYPE === "shopify") {
itemId = "shopify_" + PRODUCT_COUNTRY_CODE + "_" + item.product?.id + "_" + item.id;
} else if (ID_TYPE === "parent_id") {
itemId = item.product?.id;
} else if (ID_TYPE === "sku") {
itemId = item.sku;
if (CAPITALIZE_SKU) {
itemId = itemId.toUpperCase();
}
} else {
itemId = item.id;
}
return {
id: itemId,
item_name: item.product?.title,
price: item.price?.amount,
quantity: 1
};
};
const calculateTotalDiscount = (lineItems) => {
let totalDiscount = 0;
lineItems.forEach(item => {
item.discountAllocations.forEach(discount => {
totalDiscount += parseFloat(discount.amount.amount);
});
});
return totalDiscount.toFixed(2); // Convert to string with 2 decimal places
};
analytics.subscribe("checkout_completed", (event) => {
const lineItemsData = createLineItemsData(event.data?.checkout?.lineItems, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU);
const email = event.data?.checkout?.email;
const phone = event.data?.checkout?.phone;
const address = event.data?.checkout?.shippingAddress;
const totalDiscountAmount = calculateTotalDiscount(event.data?.checkout?.lineItems);
let shopifyPixelData = {
currency: event.data?.checkout?.subtotalPrice?.currencyCode,
value: event.data?.checkout?.subtotalPrice?.amount,
transaction_id: event.data?.checkout?.order?.id,
shipping: event.data?.checkout?.shippingLine?.price?.amount,
tax: event.data?.checkout?.totalTax?.amount,
};
if (email) {
shopifyPixelData.email = email;
}
if (phone) {
shopifyPixelData.phone = phone;
}
if (address) {
let addressData = {};
if (address.firstName) addressData.first_name = address.firstName;
if (address.lastName) addressData.last_name = address.lastName;
if (address.address1) addressData.street = address.address1;
if (address.city) addressData.city = address.city;
if (address.province) addressData.region = address.province;
if (address.zip) addressData.postal_code = address.zip;
if (address.provinceCode) addressData.province_code = address.provinceCode;
if (address.country) addressData.country = address.country;
if (address.countryCode) addressData.country_code = address.countryCode;
if (Object.keys(addressData).length > 0) {
shopifyPixelData.address = addressData;
}
}
shopifyPixelData.aw_merchant_id = GOOGLE_MERCHANT_CENTER_ID;
shopifyPixelData.aw_feed_country = address.countryCode;
shopifyPixelData.discount = totalDiscountAmount;
shopifyPixelData.shipping = event.data?.checkout?.shippingLine?.price?.amount;
shopifyPixelData.estimated_shipping_time = ESTIMATED_SHIPPING_TIME;
shopifyPixelData.items = lineItemsData;
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "purchase",
url: event.context.document.location.href,
ecommerce: shopifyPixelData
});
});
analytics.subscribe("product_added_to_cart", (event) => {
dataLayer.push({ ecommerce: null });
const items = createLineItemsDataAddToCart(event.data?.cartLine, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU);
dataLayer.push({
event: "add_to_cart",
url: event.context.document.location.href,
ecommerce: {
currency: event.data?.cartLine?.merchandise?.price?.currencyCode,
value: event.data?.cartLine?.merchandise?.price?.amount,
items: items
}
});
});
analytics.subscribe("cart_viewed", (event) => {
dataLayer.push({ ecommerce: null });
const items = createLineItemsDataCart(event.data?.cart?.lines, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU);
dataLayer.push({
event: "view_cart",
url: event.context.document.location.href,
ecommerce: {
currency: event.data?.cart?.cost?.totalAmount?.currencyCode,
value: event.data?.cart?.cost?.totalAmount?.amount,
items: items
}
});
});
analytics.subscribe("checkout_started", (event) => {
dataLayer.push({ ecommerce: null });
const items = createLineItemsData(event.data?.checkout?.lineItems, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU);
dataLayer.push({
event: "begin_checkout",
url: event.context.document.location.href,
ecommerce: {
currency: event.data?.checkout?.currencyCode,
value: event.data?.checkout?.subtotalPrice?.amount,
items: items
}
});
});
analytics.subscribe("payment_info_submitted", (event) => {
dataLayer.push({ ecommerce: null });
const items = createLineItemsData(event.data?.checkout?.lineItems, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU);
dataLayer.push({
event: "add_payment_info",
url: event.context.document.location.href,
ecommerce: {
currency: event.data?.checkout?.currencyCode,
value: event.data?.checkout?.subtotalPrice?.amount,
items: items
}
});
});
analytics.subscribe("checkout_shipping_info_submitted", (event) => {
dataLayer.push({ ecommerce: null });
const items = createLineItemsData(event.data?.checkout?.lineItems, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU);
dataLayer.push({
event: "add_shipping_info",
url: event.context.document.location.href,
ecommerce: {
currency: event.data?.checkout?.currencyCode,
value: event.data?.checkout?.subtotalPrice?.amount,
items: items
}
});
});
analytics.subscribe("search_submitted", (event) => {
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "search_submitted",
url: event.context.document.location.href,
ecommerce: {
query: event.data?.searchResult?.query,
}
});
});
analytics.subscribe("collection_viewed", (event) => {
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "view_collection",
url: event.context.document.location.href,
ecommerce: {
collection_id: event.data?.collection?.id,
collection_title: event.data?.collection?.title,
}
});
});
analytics.subscribe("product_viewed", (event) => {
dataLayer.push({ ecommerce: null });
const items = createLineItemsDataProductView(event.data?.productVariant, ID_TYPE, PRODUCT_COUNTRY_CODE, CAPITALIZE_SKU);
dataLayer.push({
event: "view_item",
url: event.context.document.location.href,
ecommerce: {
currency: event.data?.productVariant?.price?.currencyCode,
value: event.data?.productVariant?.price?.amount,
items: items
}
});
});
analytics.subscribe("page_viewed", (event) => {
window.dataLayer.push({
event: "page_view",
url: event.context.document.location.href
});
});
Go to Shopify > Settings > Customer Events
Click on add custom pixel
Paste your code, click on save and then connect.
In Google Tag Manager, go to admin > and click on import container.
GTM JSON File
If you have already installed a previous version, please merge the new file. The only thing you need to do after mergin, is to re-updated the Conversion ID and Conversion Label
Download the json upgrade from V1.07 to V1.0813
Download the full json file V1.0813
In Google Tag Manager select the file you uploaded.
Chosing your workspace, click on existing and choose default workspace
Select Merge as the import option
Click on confirm
Go to Workspace > Tags > Click on Google Ads Shopify Pixel Conersion Tracking By FeedArmy
Hover over the tag and click on edit
Add your Google Ads conversion ID and Label when creating a new conversion.
In Google Ads go to Goals > Summary > Click on New Conversion Action
Select website
Enter any website domain, and click on scan
Scroll to the bottom of the page and click on Add a conversion action manually
Add your conversion action details:
For Goal and action optimization select purchase
For Conersion name, add any name, I recommend Shopify GTM Pixel
For the Value select Use different values for each conversion
Click on Done, then click on save and continue
Select Google Tag Manager and copy your id and label from Google Ads and paste it in Google Tag Manager
Now repeat the steps for the micro tracking (optional) (view the instructions video for more details) and ensure everything is set to secondary as goal, unless you know what you are doing:
- Add To Cart
- Cart Viewed
- Begin Checkout
- Add Shipping Info
- Payment Submitted
- Search
- View Collection
Save the tag, and now lets publish the GTM container by clicking on Submit
Add a version name and click on publish
Let’s enable enhanced conversions in Google ads by clicking on done, then select your conversion action and click on ehanced conversions.
Check the box next to Turn on enhanced coversions
Check the radio button for Google tag or Googel Tag Manager and select next
Enter just a letter d, and click on check URL, as we want to force an error.
We can now click on select one manually
Click on Google Tag Manager > Next and click on save
You are now finished with the whole setup. Please leave a review to help my business and to continue to provide great free content
Google Analytics 4 Setup
If you are not upgrading from a previous version simple skip the below steps until you read, continue GA4 Installation.
If you are upgrading from V1.07 to v1.08, make sure to copy full Shopify Pixel code, or you can just replace everything below the settings of the code (only the code has changed not the settings)
Then in Google Tag Manager, import the upgrade file and edit the following two tags by adding the Google Analytics Measurement ID:
Continue GA4 Installation: We now need to add our Measurement ID
- Tags:
- Google Analytics 4 Data
- Google Analytics 4 Page View
You can find your Google Analytics Measurement ID by going to:
- Google Analytics
- Cog Icon (admin)
- Under Data collection and modification, choose Data Streams
- Click on your data stream
- Now you can view and copy your measurement id
Now click on both tags, and add replace the G-1234 that I added, with your own measurement ID.
Support My Work!
https://www.trustpilot.com/review/feedarmy.com
or here : https://g.page/r/CbGZ-JICOoh1EAg/review
Trouble Shooting
Browser Console Log (developer tools)
Because Shopify pixels run in sandbox mode, for privacy reasons you will not be able to view data layers in your browser.
Conversion Not Working
If your conversions are not working, then most likely your theme checkout and thank you page are not published.
Go to Shopify > Online Store > Themes > Click on Customize
Click on the home page drop down and select Checkout and new customer accounts
Click on checkout drop down and choose thank you and or checkout (whichever says unpublished)
Click on the sections button and publish.
Change Log
- 25th August 2024: V1.08+ now supports Google Analytics 4
- 8th August 2024: V1.07+ now supports micro conversions + bug fixes
- 16th July 2024: Updated GTM enhanced conversion data to be lowercase, as per documentation and highlighted by Lowie Verschelden
- 14th July 2024: Added V1.05 cart data, so that you can use Google Ads cost of goods based bidding.
- 18th June 2024: Added conditional checks for enhanced data to avoid listing empty values
- 10th June 2024 : Updated GTM Container, incorrect mapping of some variables (to update please delete all variables in GTM, and re-import with merge option)
Shopify Pixel
This Shopify Pixel / Customer Event code, has been tested and verified as working for Shopify merchants that have enabled Checkout Extensibility.
The first step is to get your conversion id and label.
Log in to Google Ads and go to Goals > Conversions > Summery
Click on the blue button that says + New conversion action
Select Website as your conversion method.
Enter your website address, and scan.
If you see a banner that says to use Google Analytics, then click on Use Google Ads only
Click on +Add conversion action manually.
- Choose Purchase as your Goal and action optimization
- Enter any conversion name, I will call it Shopify Pixel
- Select Use different values for each conversion
- Leave the rest unchanged and click on done
Click on See event snippet
Copy the code and paste in a temporary text file, we will copy some details at a later stage.
Click on Done.
Now go to Shopify > Settings > Customer Events
And click on Add custom pixel
You can give it any pixel name, but I will call it Google Ads Conversion. Now click on Add pixel.
When editing the code below, please do not remove or change the author, and respect who built it.
// Created by FeedArmy V1.04
Paste the below code in the Shopify pixel.
// Created by FeedArmy V1.05
const script = document.createElement('script');
script.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=AW-123456789');
script.setAttribute('async', '');
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-123456789', {'allow_enhanced_conversions':true});
analytics.subscribe("checkout_completed", (event) => {
gtag('set', 'user_data', {
email: event.data?.checkout?.email,
phone: event.data?.checkout?.phone,
address: {
first_name: event.data?.checkout?.shippingAddress?.firstName,
last_name: event.data?.checkout?.shippingAddress?.lastName,
street: event.data?.checkout?.shippingAddress?.address1,
city: event.data?.checkout?.shippingAddress?.city,
region: event.data?.checkout?.shippingAddress?.province,
postal_code: event.data?.checkout?.shippingAddress?.zip,
provinceCode: event.data?.checkout?.shippingAddress?.provinceCode,
country: event.data?.checkout?.shippingAddress?.country,
countryCode: event.data?.checkout?.shippingAddress?.countryCode,
}
});
gtag('event', 'conversion', {
send_to: 'AW-123456789/abcdefg123456789',
transaction_id: event.data?.checkout?.order?.id,
value: event.data?.checkout?.subtotalPrice?.amount,
currency: event.data?.checkout?.subtotalPrice?.currencyCode,
});
});
From your previously copied code from Google Ads, copy the AW-123456789 id highlighted in the image below.
And paste it twice on row 3, and row 10, by replacing the existing ID AW-123456789 (shown in red in the image above)
Go back to your Google Ads code and now copy the full ID and Label as highlighted in the image below.
Replace the send_to value between the quotes on row 14. (shown in red in the above image)
Now click on save in the top right corner followed by clicking on Connect, accept Shopify terms and conditions. And you are all done.
Testing
You can’t test code on Shopify’s checkout thank you page because it’s in sandbox mode, meaning tools like Google Tag Assistant or GTM Preview Mode won’t work. While you could use console.log to check data, I think it’s unnecessary effort. The code does work. Simply wait for a sale to confirm that it’s tracked in Google Ads as a conversion when it comes from an ad click or wait until you have any sale, Google Ads will show the code is detected.
Change Log
- V1.05 – 20 May 2024: Changed the order of gtags
- V1.04 – 20 May 2024: Added user_data values after Sve (comment below) confirmed Google’s own version. I already built this months ago, but needed confirmation it’s correct.
- V1.03 – 02 March 2024 : Supports multicurrency and used subtotal price instead of total
- V1.02 – 27 February 2024 : Public Release
Support My Work!
My conversion tracking code is constantly updated and provided free for anyone to use. As I don’t ask for any monitary value in return, I would be grateful if you consider leaving a review: https://www.trustpilot.com/review/feedarmy.com
Additional Scripts
Supported Functions
- Automatically supports multi currencies.
- Automatically converts European prices with commas to dots.
- Optional choice for disabling tax and shipping in your checkout value.
- Includes the new Google Ads enhanced conversion option
Requirements
- Access to Google Ads > Conversions
- Access to Shopify > Settings
Step 1: Open Shopify Checkout Settings
Open a new tab in your browser and log in to your Shopify Admin Panel
Navigate to Settings (Gear Icon) and choose Checkout
Step 2: Setup & Copy Your Google Ads Conversion Code
In a second browser tab, login to Google Ads and click on the tools and settings menu in the top right corner and select Conversions under the Measurement column.
Click on the big blue plus sign (New Conversion Action).
Now select website as your tracking template.
It will now ask you to scan your website URL. Enter your URL and click on scan.
Scroll to the bottom and choose to install the conversion action manually.
Then do the following :
- Conversion name
- enter any name
- Category
- Purchase / Sale
- Value
- Use different values for each conversion
- Attribution model
- Choose Position-Based (recommended for growth based businesses)
- The rest can be as default
I have written a great article on how to choose your attribution model.
Click on Create and continue
Now you can click on Save And Continue
Click on See Event Tag
Copy your Event Snippet and save it in a temporary file, for later use.
Click on Done
Click on the recently added conversion action
Enabling Enhanced Conversions is optional and not required. Some accounts may not see this option yet. So you can continue the steps below, excluding those related to enhanced conversions. (Skip to Step 3)
Now go to Tools and Settings > conversions > settings or click here: https://ads.google.com/aw/conversions/customersettings
By enabling enhanced conversions you allow Google to improve its accuracy to track conversions. This seems to be required due to Apple’s IOS14 no tracking prompt.
After you have checked the box and clicked on save, you will get a terms and conditions prompt, read it and confirm.
Now choose Google Tag and click on Tag Details.
Now check the box next to Specify CSS selectors or JavaScript variables
- Change CSS selector to Global Javascript variable
- Enter the following values for Email
- enhanced_conversion_data.email
Repeat the steps for Phone number and Name and Address
- Phone
- enhanced_conversion_data.phone_number
- First name
- enhanced_conversion_data.first_name
- Last name
- enhanced_conversion_data.last_name
- Street address
- enhanced_conversion_data.home_address.street
- City
- enhanced_conversion_data.home_address.city
- State
- enhanced_conversion_data.home_address.region
- Country
- enhanced_conversion_data.home_address.country
- Postal code
- enhanced_conversion_data.home_address.postal_code
You might ask, why the javascript values? Well on your thank you page, the javascript selector for all the values is added as a javascript variable when using the conversion tracking code below (From V1.5). This will only work if you use the code below.
Step 3: Editing and Pasting Your Google Ads Conversion Tracking
Go back to Shopify and scroll down until you see Order Processing (from step 1), at the bottom of this section you will have a field where you can paste code that is labeled Additional Scripts.
If you have two fields such as post purchase and order status, then add the code to the order status field.
Copy the send_to value (image below) and replace fa_send_to value with your value in the code template below.
- replace the value for fa_send_to
- replace the value AW-123456789/abcdefghijlklmnopq with your event snippet send_to value
- Choose yes or no for fa_include_tax_and_shipping
- choose yes if you want to include tax and shipping in the checkout value or no to not include tax and shipping values.
Sometimes on rare occasions, when you set fa_include_tax_and_shipping to no, it would still include the shipping. I’m not sure why this sometimes happens, but it might have to do with the account country. So if you notice shipping is included, set the value to yes, and it will remove shipping.
Code Template (change the fa_send_to value with your code snippet send_to value)
<!-- FEEDARMY START Global site tag (gtag.js) - Google Ads V2.2 -->
<!-- For the latest and updated code or tutorial: https://feedarmy.com/kb/adding-adwords-conversion-tracking-to-shopify/ -->
{% assign fa_send_to = 'AW-123456789/abcdefghijlklmnopq' %}
{% comment %}DO NOT EDIT BELOW{% endcomment %}
{% if fa_google_coding %}{% assign fa_google_coding = true %}{%- else -%}{% assign fa_google_coding = false %}{%- endif -%}
{% assign fa_google_ids = fa_send_to | split: "/" %}
{% if fa_google_coding == false %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{fa_google_ids[0]}}"></script>
{%- endif -%}
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{fa_google_ids[0]}}', {'allow_enhanced_conversions':true});
var checkout = window.Shopify.checkout;
</script>
{% if first_time_accessed %}
<script>
gtag('event', 'conversion', {
'send_to': '{{ fa_send_to }}',
'value': checkout.total_price_set.presentment_money.amount,
'currency': checkout.total_price_set.presentment_money.currency_code,
'transaction_id': '{{ order_id }}',
});
var enhanced_conversion_data = {
{% unless billing_address.first_name == blank %}"first_name": "{{ billing_address.first_name }}",{% endunless %}
{% unless billing_address.last_name == blank %}"last_name": "{{ billing_address.last_name }}",{% endunless %}
{% unless checkout.email == blank %}"email": "{{ checkout.email }}",{% endunless %}
{% unless billing_address.phone == blank %}"phone_number": "{{ billing_address.phone }}",{% endunless %}
"home_address": {
{% unless billing_address.street == blank %}"street": "{{ billing_address.street }}",{% endunless %}
{% unless billing_address.city == blank %}"city": "{{ billing_address.city }}",{% endunless %}
{% unless billing_address.province_code == blank %}"region": "{{ billing_address.province_code }}",{% endunless %}
{% unless billing_address.zip == blank %}"postal_code": "{{ billing_address.zip }}",{% endunless %}
{% unless billing_address.country_code == blank %}"country": "{{ billing_address.country_code }}"{% endunless %}
}
};
</script>
{% endif %}
<!-- FEEDARMY END Global site tag (gtag.js) - Google Ads V2.2 -->
Verifying and Testing
Verifying
You can verify if the code is working if you go to Google Ads > Tools and Settings > Conversions > here check if the status is verified.
Testing
First open up Tag Assistant when the new window opens up make a test payment to check if the conversion tracking is correctly installed. When you are on the final thank you page check the data within Tag Assistant.
Tip:
first_time_accessed
is for the page, not for the customer. Subsequent orders will run afirst_time_access
again for the same person if it is a new browser session.
Trouble Shooting Enhanced Conversions
Make sure you have waited at least 3 to 7 days. Google requires time to compile the data.
Coverage:
You may encounter issues with regard to coverage. This can happen when customers pay through a third-party payment processor (PayPal), which may require that they enter customer data on a different domain instead of directly on your website like they do when they do not use a third-party payment processor.
Match status:
If you are having issues with the match status, not all users fill out all the fields in your checkout. What you could do is remove the attributes in your Google Ads conversion list to only track emails or only track mandatory fields in your checkout.
By removing non-mandatory fields, you will avoid submitting empty fields to Google.
Change Log
- 8th September 2023 – updated the steps for enhanced conversion tracking
- V2.2 – 11 July 2023 – updated code to validate every value
- V2.1 – 24 June 2023 – updated checkout price to use presentment_money
- V1.8 – 10 August 2022 – Added enhanced conversion checks for email and phone number
- V1.7 – 07 June 2022 – Fixed incorrect total value when changing shipping and tax settings
- V1.6 – 28 April 2022 – Fixed the country code not adding the value correctly as highlighted by Jon Yildiz
- V1.5 – 27 July 2021 – Added Enhanced Conversions using Javascript and removed CSS
- V1.4 – 21 July 2021 – Added Enhanced Conversions using CSS
- Due to server migration, older changes are not listed
Support My Work!
My conversion tracking code is constantly updated and provided free for anyone to use. As I don’t ask for anything in return, I would be grateful if you consider leaving a review: https://www.trustpilot.com/review/feedarmy.com
Enable Google Ads Remarketing Pixel For Shopify
Track your existing website visitors by installing remarketing for Shopify. A returning visitor is twice as likely to convert as a first-time visitor. Use this data for display remarketing ads and audience targeting.
Enable Micro Conversions
If you like to track more minor conversion actions ie, micro-conversions such as add to cart, view cart, add a delivery address. Then install Google Analytics Goals.
the new edition of the code, do not send the Conversion value to google ads, only send Conversions.
My apologies; I don’t know what happened. The event triggers were not changed in the file I uploaded, but they were correct in my final version. I think something happened when I exported that I chose the wrong version. This is now correct. Please download the upgrade file for v1.0813. Thank you for reporting the issue.
Hi Emmanuel, first of all, thank you for this guide, you are AMAZING and you will be our go to person for hired help. I have a question about the ID_Type. How do you know which id_type you have? Also, if consent mode is set to false, will it affect ad performance? Thanks in advance for your help!
Hello Sam, Thank you kindly. It’s my pleasure. To find out what ID format you are using, either go to Google Merchant Center > Products or go to Google Ads > click on a shopping or PMax campaign > click on products.
If forced consent mode is set to false, it means the cookie consent popup you are using will be the one that determines if it tracks or not. If you set it to true, it will set consent mode to true and ignore anything the customer has chosen if you are using a cookie banner. The cookie banner should handle it. There are plenty of apps that can do this.
Thanks for the quick response! Last question about this I promise. It appears that we have product IDs that are a combination of custom product IDs (ie PPDF54784754) because some products were uploaded manually, and shopify product ids (ie shopify_US_XXXX format) for products that came in via the Content API. In the case where we have a blend like this, what should we use for the ID_Type?
In that case choose one or the other, but I would say use the Shopify ID. It is recommended to avoid having different types of ID’s as this will only hurt your remarketing and cart data tracking.
Can you please help me understand how this function works using for feedarmy-new-returning-customer function variable? I don’t see anything regarding this in the datalayer code.
function () {
if (customer.ordersCount > 1) {
return true
} else {
return false
}
}
Currently this is not a supported function.
Thank you for this detailed guide. Unfortunately I am getting the “attention required” error in the Google Tag Manager. I have pages which aren’t tagged and the other error says consentmodus has been installed in the wrong order.
I don”t even know how to install the consentmodus, i just followed the steps in this guide.
Then in Google Ads as I am just copying everything you say should i enable enhanced conversions also for Cart Viewed, Payment Submitted, Search, Shipping and View Collection? What value should I choose? For GTM Pixel Purchase you said to use different values but i’m confused about the others.
Then the last two questions which show how much of a noob I am, should the the code which you paste under the part in your theme editor also be added? Or is it added already because of the code we pasted in the shopify pixel?
And is it normal that in the Tag Manager Admin center I have my account and container which is okay but then the next tab which says “Google-Tags”‘ there aren’t any google tags there.
Thank you for the help
Hello, yes, some pages are not tagged on pixel codes V1.07 and below, all pages are tagged for v1.08 and above.
Regarding consent mode, best to use an app to help guide you what to do and if you are still stuck, contact the app support team.
For micro conversions keep it as default, and only use these conversion actions for advanced campaign management.
Do not add any coding in the theme editor. All the necessary coding is within my code for the Shopify pixel.
I am not sure about your Google-Tags question, that requires investigation. You may reach out to me at [email protected] for personal service.
Hi Emmanuel! Thank you so much for this solution! However, we’re encountering one problem – when a user goes to the product page, the view_item event fires and all the item data is recorded, but when they switch to variant of the product, it doesn’t work. Although the information on the page changes and the url as well (page path changes from /layout-2-seat-sectional to /layout-2-seat-sectional?variant=123456789), apparently the page doesn’t fully reload. Is there a way to fix this and make view content fire on this variants as well?
Hello Anna, currently the triggers will only fire on page reloads / loads. I’m sure there is a way to get this working, however that requires custom coding, as each merchant will have different variant option tags.
Got it, thanks!
Shouldn’t there be a tag for “Product viewed”? It’s missing. Only “Collection viewed” is available.
I don’t see the benefit of tracking product views, considering a click on a shopping ad goes directly to the product page, meaning it won’t give you more info than you already know. Or are you talking from the perspective of advertising text ads for other pages, than seeing if they reach the product page?
The tags are not firing, what could it be?
For example, a step was not taken correctly. And are you aware you can not view tags when using pixels. Shopify runs this in sandbox mode, which is privacy locked. Thus you can’t view the results using the console. You will need to wait a day, and view the results in Google Ads.
Hi the web agency I work with set up a pixel already to track purchases on GA4 which I working okay. However for GAds I want to use your one as it includes enhanced conversions and cart data. Will me uploading this interfer with their pixel tracking? I’m worried the purchase event will fire twice since it looks like you are using the same naming structure now. Could I just stick to version 1.07? Thanks so much for this by the way it is amazing!
For V1.07 it will not double track as the event names are non default, but for V1.08 I had to change it to be default event naming convention, which will cause issues if you already have GA4 installed via GTM. In this case if you would like to upgrade, best to pause your existing GA4 integration in GTM.
Is it necessary to do this if I already have the Google & YouTube app installed? And if so, do I have to disconnect the app?
No, it is not necessary. Merchants install my version of the script because the Google and YouTube Apps can randomly stop working. You don’t need to disconnect the app; you can simply delete the old conversion actions in Google Ads.
Great! Thank you very much for replying, I really appreciate it.
Pleasure
How do we add a new Customer variable like we used to do in Additional Script?
That is being tested currently.
Hi – If I already have V1.5+ setup, is it ok to just go over the process above again? I.e., uploading the json file to GTM won’t cause any conflicts with previous uploaded file? Thanks.
You will need to delete the old conversion tag, because I changed the naming convention of all the tags. So if you import and don’t remove the old tag, then you have 2 tags causing double tracking. But that is it.
Can you please provide me with the json file you imported in GTM?
Here you go: https://feedarmy.com/wp-content/uploads/2024/08/GTM-Shopify-Google-Ads-Enhanced-Conversion-Tracking-Pixel-v1.07.zip
i think there’s an issue in the latest version, since the import gives back: JSON parsing error: mismatched input ‘7’ expecting {‘{‘, ‘[‘}. Earlier versions work fine.
I just did a test on a clean workspace, by importing the migraion file and the full version, with no errors. I believe you may have encountered an issue that is not related to the JSON file itself. Feel free to contact me at [email protected] if you need assistance.
Hi Emmanuel, thanks for your help, we use your work daily – it’s genuinely amazing.
We’ve followed the steps from v1.07. However, I can’t see any of the events in the summary section of GTM debug (eg view product, add to cart, start checkout, purchase). Why this might be? Also the google tag is not present when doing a purchase? Do you know any ways to fix this?
Again many thanks for your contributions to the community.
Felix
Thank you kindly Felix 🙂
When using GTM debug, and because Shopify Pixels run in privacy mode (sandbox mode) no data is visible and no coding is visible.
To ensure it works, wait a day for conversions to show up, and wait a week or so for enhanced conversions to show up.
Understood! Thanks a ton. Also we don’t know the const ID_TYPE as this client is not eligible for google merchant centre. How may we find out if its whether sku, parent, or variant? Appreciate you man!
If you are not using Google Merchant Center, then the product ID is irrelevant and as you can imagine, you can not know what the ID is. Only by having a GMC account, can you know what the ID is being used.
Hey Emmanuel, thanks for this, we use your work daily – it’s amazing!
I had a question:
After following the steps. When previewing with Google Tag Manager, I don’t see the google tag being found (there’s the gtm and Google Analytics tag only). Do I need to install the Google Tag in the script?
Please let me know, thanks again for your contributions to the community.
Felix
Thank you again for the reply.
When using GTM debug, and because Shopify Pixels run in privacy mode (sandbox mode) no data is visible and no coding is visible.
To ensure it works, wait a day for conversions to show up, and wait a week or so for enhanced conversions to show up.
Hi Emmanuel,
I went ahead and added your code to my shopify site, imported your JSON file successfully into my GTM account, and created an appropriate purchase Conversion in my Google Ads account. After completing those steps, my Conversion has a status of “Inactive” and displays “We haven’t verified your tag yet, which usually takes up to 3 hours after someone visits your page containing the tag. To help speed this up, you can visit the page to trigger the tag.” When I hover over the status. This is typical after immediately making the change, correct? If so, do you know roughly how long it takes for the Conversion to become “Active”. Thanks for the help!
If you have waited 2 days, and it is not working. Than contact me at [email protected]
Hi Emmanuel,
Thank you for your content!.
Can enhanced conversions be enabled simply by checking the “Enhanced Conversion Setup” checkbox on the Google Conversion action page for a Shopify app-based conversion action, without using GTM?
In the Google Ads account I manage, conversion tracking was implemented using the Shopify app without GTM before I took over.
It is tracking sales revenue correctly
Two days ago, I enabled “Use enhanced conversions” for this conversion action, and the enhanced conversion status is now “Managed Through Google Tag. Enhanced Conversions are being recorded.”
How can I ensure that enhanced conversions are indeed working? Should GTM also be installed as described in your post?
Thanks
If you are using a Shopify app to track conversions, you will need to check with the app support to see if enhanced conversions is supported.
Normally you can view the diagnostics of the conversion action to check if enhanced conversions is working or not. But what data is submitted I would not know. With my coding, I am maximizing the data sent to Google to allow for maximum tracking.
Hey Emmanuel
We are huge fans of your work! I have a question about the consent mode settings in the new code – my understanding is that this is set when someone enters the website but I can see that the new code updates this consent when someone purchases – is that correct?
So technically if someone does not consent when entering the site but then makes a purchase, this code will update their consent to ‘yes’ without them knowing?
Thanks so much
Hannah
Good question. I’m not 100% knowledgeable about consent; I followed Shopify’s documentation here: https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/gtm-tutorial
I will do more research about consent mode, and see what I need to do. You may remove the consent mode update if you want.
Good to know and thank you for the response 🙂 appreciate it!
Pleasure
Hi Emmanuel, thank you so much for the scripts, so kind of you to share. I have added the Shopify Pixel + Enhanced Tracking script as per your instructions. The new conversion action is picking up fewer conversions with a lower conversion value than the current checkout additional scripts method so I am reluctant to switch it to primary in my account. Can you suggest why this may be? And what I can do to resolve this? Many thanks.
The lower sales value will most likely be due to your old script including shipping.
The lower sales volume, should not happen. So not sure why that is. I have tested hundreds of accounts and the sales volume will be equal or greater.
Firstly, I appreciate the straightforward tutorial and neat implementation!
I installed the pixel yesterday and it recorded a sale in Ads, but the consent and enhanced conversion aren’t showing as active next to the conversion. Should I expect a delay?
Additionally, I want to include the shipping cost in the conversion value. What modifications are needed in the pixel code?
Happy to help set up the coding to include this, feel free to reach out at [email protected]
How do we amend it if there are two merchant centres and a lot of different countries?
There is no need, as it will track all conversions.
However if you meant that you have different ID’s you should use the same IDs for every feed, to avoid having to install the code multiple times.
This is the same for remarketing, to avoid having to add the remarketing code multiple times, the product IDs should all be the same.
Thanks. The Item IDs are the same across all feeds. I just meant what do I put here if there are different country codes and two different merchant centers. Or does it not matter so much, I can just put the main country UK?
GOOGLE_MERCHANT_CENTER_ID = ‘123456789’;
PRODUCT_COUNTRY_CODE = ‘US’;
The country code, is for the product, so if you are using the default shopify id’s then for UK, it is GB
Hi,
Not really understanding the product_country_code part of it all. We have a merchant center but have multiple country codes, one for each country we sell in. So, the same product could have FR, DE, GB, SE etc.
How do you handle that?
That requires some custom coding, please reach out at [email protected] and happy to code this for you.
How can we test it is it working properly or not ? as google tag assistance is not working for shopify custom pixel
Pixels are run in sandbox mode, which means, you can not view the data for privacy reasons. You will need to wait 1 or 2 days for a conversion to take place, then the status will update in Google Ads.
Currently I have “website unknown” triggering with a conversion value in my Google ads conversion data under webpages. Does this have to relate to any incorrect tagging. I am using additional script at this moment, would migrating to shopify pixel work ?
and if it works, I have a global targeting so would this work for multiple currency purchases ? currently my shopify converts the currencies coming to a Single currency and shows the data.
Any insights would be much appreciated .
I have looked at my current clients and I can see webpage unknown, but for 5% of all conversions. Not sure if this is cause for concern, unless you fear some other website has installed conversion tracking with your label. However if you do fear about this, create a new conversion action, so the label is new. And yes my conversion code supports multiple currencies.
Just checking as my question relevant…
I have been using the “Google & Youtube” App – and I have noticed that it has been recording all value amounts as our default currency (GBP). So for example when a customer pays €179,95 I need it to feed the correct GBP Value (£149.88) back to Google Ads.
I just want to confirm that your solution will fix this issue – and relay the correct currency(ies) back into Google Ads?
Conversion values will be in the currency of how customers pay. In Google Ads, all non-default currencies will auto-convert to the default currency using the daily currency rate. Unfortunately, my code does not automatically convert currencies, as Shopify does not share any currency other than the one that was paid for.
I think the issue with conversion action via the “Google & Youtube” app was that there was no “Default Value Currency” selected within the settings – I have now changed this to our Shopify default of GBP, so hopefully that will fix things, would you tend to agree with that? I have also set-up your pixel as a secondary action, and will monitor them both closely.
Thanks for your reply
I would not know the reason why Google and Youtube app does not work correctly, I have always used my own coding.
Hi there! Can you please help? I keep getting stuck at the very beginning no matter which tutorial I watch. On the “conversion actions page,” under value, you chose “use different values for each conversion,” but I don’t have that option. I only have “use the same value for each conversion” and “Use the value from the Google Analytics 4 property” and “Don’t use a value for this conversion action (not recommended)”. I’m sure I followed all previous steps correctly as I’ve watched multiple videos to see why my page keeps giving me a different option.
At the top of that page, you will see a toggle to change to Google Ads tracking, not GA4.
That option doesn’t exist for me, I would provide a screenshot but it seems like links or images aren’t allowed.
There will be an option just after adding the website URL to change to Google Ads.
However if you are not able to resolve the issue, you may get personal assistance at [email protected]
Omg thank you so so so much! You saved me, you’re an angel in disguise! The fact you took the time of the day to respond and help even when you didn’t have to is so much appreciated! It would have been a bummer if I paid for google ads and wasn’t able to track anything. You’re the best!
My pleasure.
Hi there,
firstly I want to say thank you for the information you provide thats also all for free, truly amazing work!
I have a question regarding shopify pixel + enhanced tracking.
for many clients, I’ve been using the additional scripts method and so far has worked each time.
as shopify is deprecating additional scripts, by following your tutorial now, would there be any difference at all if I move over and follow your shopify pixel method?
meaning, if I used the additional scripts method, would following your shopify pixel + enhanced tracking method be exactly the same thing, except implemented differently.
If there is no difference, please let me know.
thank you!
No, it will not be exactly the same, version 1.06 has a lot more features and is a lot more advanced then the old additional script version.
hey Emmanuel! I’ve already updated all of my clients to use the earlier version which is set up via adding GTM to Shopify pixel, and then conversion tracking via GTM.
I can’t test this new version, because it would mean redoing all the GTM pixels inside my clients Shopify stores. I know that the new version includes cart data, so we can use Google Ads cost of goods based bidding, but I don’t understand this. Couldn’t we already used COGs based bidding with the earlier versions? I can see the revenue, checkout link and number of items sold pulling through into Google Ads from the earlier versions of code installed.
Just trying to understand the difference between the previous version and the new versions 🙂 Thanks!
The previous version, did not include, merchant id, product id, etc. The new version includes all the attributes, except for language, as that was a bit hard to decide how to implement, due to merchants having multiple feeds and languages.
Hi Emmanuel! Quick question, do you know how would I do this but only the first time a customer purchases something on my store and not just everytime? I’m migrating it from Additional Scripts to Custom Pixels and first_time_access is not available there, so wondering if there’s a way to do it that you know of.
This is already handled automatically using the order ID, if you like to learn more: https://support.google.com/google-ads/answer/6386790
That’s great, thank you very much!!
Hey – great work – does the JSON file link need updating? Looks like 1.02 still?
Hello Sean, Yes, the JSON file needs to be imported and merged. You will also need to re-add the conversion ID and label in GTM.
And yes, it looks like the link did not update, my apologies; this is now updated, and you can access it here: https://feedarmy.com/wp-content/uploads/2024/07/GTM-enhanced-conversions-cart-data.json
Hi Emmanuel, thank you for this guide it’s super helpful! Quick question – our website already had the Gtag installed through using the Google app on Shopify. When I came to tick the enhanced conversions radio box it was pre-checked as enhanced conversions were already being tracked using the Gtag. Is this an issue for the overall conversion tracking or will it still record enhanced conversions OK?
Thanks
When setting up the conversion action in Google Ads, the enhanced conversions must use google tag manager to track these, not GTAG.
Hi Emanuel,
Thanks for this tutorial! I’ve installed the Shopify pixel with enhanced tracking, and everything seems to be working well for conversion tracking values and enhanced conversions. However, when I check the GTM container, I see a warning message: “Container Quality Needs Attention –> Some of your pages are not tagged.” Do you have an idea what could be causing this?
Thanks!
Yes, the conversion tracking code will only show on the thank you page, nowhere else, so not showing on all pages sounds correct.
Thank you Emmanuel
Hey Emmanuel, Thank you for this. I have however followed all the steps, but my conversion action is still showing as inactive in Google Ads. Any ideas what to try to look for please? It’s been several days since doing it now and definitely had many conversions on the site (GA4 is currently managing the conversion tracking and reporting them successfully)
Many thanks
Tim
If you had sales from any source, and in Google Ads it does not show as detected, then something was not setup correctly. Feel free to reach out to me at [email protected] for personal support.
Thanks Emmanuel – I’ve sent you an email.