How To Add Google Ads Conversion Tracking Using Shopify Pixel

Free Shopify Enhanced Conversion Tracking Pixel For Google Ads + Micro Conversions + GA4

Add Google Ads conversion tracking to Shopify quickly. Choose from three versions:

  1. Additional Scripts: Deprecated but still installable.
  2. Shopify Pixel: Direct installation with Google Ads, excluding enhanced conversions.
  3. 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

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.

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

Install Google Tag Manager

Copy the tag id without GTM- as highlighted in the image below

Copy GTM ID

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

Shopify Customer Events

Click on add custom pixel

Shopify Add Custom Pixel

Paste your code, click on save and then connect.

In Google Tag Manager, go to admin > and click on import container.

Google Tag Manager 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

Google Tag Manager Import JSON

Click on confirm

GTM Confirm Import

Go to Workspace > Tags > Click on Google Ads Shopify Pixel Conersion Tracking By FeedArmy

Edit Tag Details

Hover over the tag and click on edit

Edit GTM Tag

Add your Google Ads conversion ID and Label when creating a new conversion.

Add Google Ads Conversion ID and Label

In Google Ads go to Goals > Summary > Click on New Conversion Action

Google Ads Create New Conversion

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

start tracking conversion

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

conversion action details

Select Google Tag Manager and copy your id and label from Google Ads and paste it in Google Tag Manager

Conversion Action ID and Label

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

Save and Submit your GTM

Add a version name and click on publish

Publish GTM

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

Google Ads Enable Enhanced Conversions

Click on Google Tag Manager > Next and click on save

Google Ads Finish

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
Google Analtyics Tag For Google Tag Manager

You can find your Google Analytics Measurement ID by going to:

  1. Google Analytics
  2. Cog Icon (admin)
  3. Under Data collection and modification, choose Data Streams
  4. Click on your data stream
  5. Now you can view and copy your measurement id
Google Analytics Measurement ID

Now click on both tags, and add replace the G-1234 that I added, with your own measurement ID.

Add Google Analytics 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

Google Ads Conversions

Click on the blue button that says + New conversion action

Google Ads New Conversion Action

Select Website as your conversion method.

Google Ads Website Conversions

Enter your website address, and scan.

Google Ads Convesrion Scan Website

If you see a banner that says to use Google Analytics, then click on Use Google Ads only

Google Ads Only

Click on +Add conversion action manually.

Google Ads Add A 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
Google Ads Conversion Settings

Click on See event snippet

Google Ads Conversion Event Snippet

Copy the code and paste in a temporary text file, we will copy some details at a later stage.

Google Ads Copy Conversion Code

Click on Done.

Now go to Shopify > Settings > Customer Events

And click on Add custom pixel

Shopify Add Custom Event

You can give it any pixel name, but I will call it Google Ads Conversion. Now click on Add pixel.

Shopify Add Custom Pixel Name

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,
  });
});
Shopify Add and Modify Conversion Code

From your previously copied code from Google Ads, copy the AW-123456789 id highlighted in the image below.

Google Ads Conversion ID

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.

Google Ads Conversion ID and Label

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

Shopify 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.

Google Ads Conversion

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

Create your website conversion action

Now you can click on Save And Continue

Google Ads Continue Conversion Action

Click on See Event Tag

Google Ads See Event Tag

Copy your Event Snippet and save it in a temporary file, for later use.

Google Ads Copy Event Snippet

Click on Done

Google Ads Conversion Action Done

Click on the recently added conversion action

Google Ads 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.

Turn on Google Ads Enhanced Conversions

Now choose Google Tag and click on Tag Details.

Turn on Google Tag and View 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
Google Ads Javascript Conversion Tracking Variables

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.

Shopify Additional Scripts

Copy the send_to value (image below) and replace fa_send_to value with your value in the code template below.

  1. replace the value for fa_send_to
    • replace the value AW-123456789/abcdefghijlklmnopq with your event snippet send_to value
  2. 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 a first_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. 

Google Ads Enhanced Conversion By Tags

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.

Google Ads Enhanced Conversions Match Status Issues

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.

Need Help?
Do you have a question or need specialist support? Get in touch!

Subscribe
Notify of
guest
357 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
ylc
ylc
4 hours ago

the new edition of the code, do not send the Conversion value to google ads, only send Conversions.

Sam Ro
Sam Ro
2 days ago

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!

Sam Ro
Sam Ro
Reply to  Emmanuel Flossie
1 day ago

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?

shadab
shadab
2 days ago

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
 }
}

Vnhrf
Vnhrf
3 days ago

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

Anna
Anna
3 days ago

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?

Anna
Anna
Reply to  Emmanuel Flossie
2 days ago

Got it, thanks!

Juan
Juan
3 days ago

Shouldn’t there be a tag for “Product viewed”? It’s missing. Only “Collection viewed” is available.

APCA
4 days ago

The tags are not firing, what could it be?

Last edited 4 days ago by APCA
Eric
Eric
5 days ago

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!

Blissa Argon
Blissa Argon
6 days ago

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?

Blissa Argon
Blissa Argon
Reply to  Emmanuel Flossie
4 days ago

Great! Thank you very much for replying, I really appreciate it.

shad
shad
13 days ago

How do we add a new Customer variable like we used to do in Additional Script?

John
John
13 days ago

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.

Haider
Haider
17 days ago

Can you please provide me with the json file you imported in GTM?

Benny
Benny
Reply to  Emmanuel Flossie
7 days ago

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.

Felix
Felix
18 days ago

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

Felix Mayo Sanchez
Felix Mayo Sanchez
Reply to  Emmanuel Flossie
11 days ago

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!

Felix
Felix
18 days ago

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

Steve
Steve
19 days ago

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!

Andrey
28 days ago

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

Hannah
Hannah
30 days ago

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

Hannah
Hannah
Reply to  Emmanuel Flossie
20 days ago

Good to know and thank you for the response 🙂 appreciate it!

Rachel
1 month ago

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.

loeloeba
loeloeba
1 month ago

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?

Zara
Zara
1 month ago

How do we amend it if there are two merchant centres and a lot of different countries?

Zara Imrie
Zara Imrie
Reply to  Emmanuel Flossie
1 month ago

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’;

Christer Ogenstad
Reply to  Emmanuel Flossie
7 days ago

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?

Last edited 7 days ago by Christer Ogenstad
Jackie
Jackie
1 month ago

How can we test it is it working properly or not ? as google tag assistance is not working for shopify custom pixel

Azi
Azi
1 month ago

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 .

Dan
Dan
Reply to  Emmanuel Flossie
10 days ago

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?

Dan
Dan
Reply to  Emmanuel Flossie
9 days ago

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

Kai
Kai
1 month ago

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.

Kai
Kai
Reply to  Emmanuel Flossie
1 month ago

That option doesn’t exist for me, I would provide a screenshot but it seems like links or images aren’t allowed.

Kai
Kai
Reply to  Emmanuel Flossie
1 month ago

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!

Matt
Matt
1 month ago

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!

Lily
1 month ago

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!

Jose
Jose
1 month ago

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.

Jose
Jose
Reply to  Emmanuel Flossie
1 month ago

That’s great, thank you very much!!

Sean
Sean
1 month ago

Hey – great work – does the JSON file link need updating? Looks like 1.02 still?

Rufus
Rufus
1 month ago

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

stoynov
stoynov
1 month ago

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!

stoynov
stoynov
Reply to  Emmanuel Flossie
1 month ago

Thank you Emmanuel

Tim
Tim
1 month ago

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

Tim
Tim
Reply to  Emmanuel Flossie
1 month ago

Thanks Emmanuel – I’ve sent you an email.

357
0
Would love your thoughts, please comment.x
()
x