How to Change Product IDs from SKU to Shopify IDs to Match Merchant Center Products

This article shows how to update the default product IDs contained in the GTM tags so your tag hits from your website match the IDs for your products in Merchant Center.

πŸ“˜

This article if for version 2.0 and higher of our Data Layer

When installing the data layer we make four variables related to product IDs available for your use:

  1. Variant SKUs
  2. Product IDs
  3. Variant IDs
  4. Shopify_us_IDs

By default, all of our tags in our pre-built container are set to SKU as the Item IDs. So if your merchant center IDs are using SKUs then you don't need to do anything further πŸ˜€!

But if you need to change the tags from sending SKU to Shopify product IDs then you will need to update a few things in GTM.

Why? Google Merchant Center product IDs need to match the item ID that we are sending with the remarketing tags. When these don't match you'll usually see errors within your AdWords audience sources.

How to Find Your Merchant Center Product ID

Inside of Google Merchant Center navigate to products and look for your item id's here:

And this is an example tag that you will need to match the same Item ID up to in GTM:

Once you have your ID format then move to the next step.

The following options below show how to change to product ID.

How to Change Item ID (aka ecomm_prodid) from SKU to Product ID in GTM

If your Google Merchant Account is using Shopify product IDs instead of variant SKUs then you will need to update 5 variables in Google Tag Manager.

What needs to be updated:

  1. js - Google Ads - Product View - SKU
  2. js - Google Ads - Collection Page - SKU
  3. js - Google Ads - Add to Cart - SKU
  4. js - Google Ads - Cart Page - SKU
  5. js - Google Ads - Purchase - SKU

From

'id': product.id

to this:

'id': product.product_id

Product View:

Navigate to Variables > js - Google Ads - Product View - SKU and update out the following areas circled in red to match the product ID variables

Collection Page:

Here is what your View Item List tag should look like:

Add to Cart:

Here is what your Add to Cart tag should look like:

Cart Page:

Here is what your Cart Tag should look like:

Purchase:

And finally here is what your purchase tag should look like:

Note:

If you'd like to adjust from variant SKU to variant id, or shopify_us_ type of id then use the examples below to update the row for IDs shown above (you can also see these instructions in the note section)

Variant Ids

from this:

'id': product.variant_id,

to this:

'id': "shopify_US_" + product.product_id + "_" + product.variant_id,

Shopify_us_IDs

Here's an example of how to use the Shopify_US_IDs:

'id': "shopify_US_" + product.product_id + "_" + product.variant_id,

For the following variables:

  • js - Google Ads - Add to Cart - SKU
  • js - Google Ads - Product View - SKU
  • js - Google Ads - Purchase - SKU

For the following variables:

  • js - Google Ads - Cart Page - SKU
  • js - Google Ads - Collection Page - SKU

Note:

  • When using other geolocation (e.g., NI, IT, CA, PH, etc,) just replace the "US" in the line.

Ecomm_prodid:

For View Item and AddToCart tags, we are sending the ecomm_prodid parameter. Thus, you'll have to update this as well if you are not using the default SKU ID

Example: Product ID

View Item

AddToCart

So the variables are:

  • Product ID:
    1. View Item: dlv - Product View - Product ID
    2. AddToCart: dlv - Add to Cart - Product ID
  • Variant ID:
    1. View Item: dlv - Product View - Variant ID
    2. AddToCart: dlv - Add to Cart - Variant ID
  • Shopify_US_IDs:
    You'll need to make a copy of the custom javascript variable shown above for each tag and update the script to the one shown below.

View Item:

function() {
 var products = ;

 return products.map(function(product) {
   return "shopify_US_" + product.product_id + "_" + product.variant_id
   
 });
}

AddToCart:

function() {
 var products = ;

 return products.map(function(product) {
   return "shopify_US_" + product.product_id + "_" + product.variant_id
 });
}

That's it!

Please feel free to contact us if you have any questions or concerns πŸ˜€