Google Merchant Center Lookup variable for Google Tag Manager server container

Ivanna Holubovska

Ivanna Holubovska

Author
Updated
Aug 21, 2026

Google Merchant Center Lookup variable is used to retrieve and enrich product data by querying information from a Google Merchant Center account. This is particularly useful for enhancing the data associated with products in your Merchant Center, such as product categories or additional attributes, when passing data to other systems like Google Ads or Google Analytics via the server-side GTM container.

Use case

For example, you’re an e-commerce company that uses Google Merchant Center to manage your product catalog and Google Ads to run Shopping campaigns. You want to track conversions and product interactions more accurately by enriching product data in the server-side Google Tag Manager (GTM) container before sending it to Google Analytics or Google Ads for reporting and optimization.

When users interact with the website, product-related data (such as product categories, brands, and other custom attributes) may not always be fully captured client-side. Some attributes might be missing from the web data layer or poorly categorized due to inconsistencies in product tagging on the front end. This results in incomplete or inaccurate data being sent to Google Ads and Analytics, potentially affecting campaign performance and reporting.

By setting up Google Merchant Center Lookup variable in the GTM server container, you can enrich the data related to product interactions by pulling additional details directly from your Google Merchant Center feed. This ensures that the product information sent to Google Ads and Analytics is accurate and consistent across all platforms.

Benefits

  • Consistent Data Across Platforms: Merchant Center Lookup ensures that all platforms (Google Ads, Analytics, etc.) are working with the same, up-to-date product information.
  • Improved Campaign Performance: Google Ads and other platforms can optimize campaigns better when they receive complete and accurate data about the products being sold.
  • Automation and Efficiency: by automating the product data lookup via the server container, the company reduces manual work and the risk of inconsistencies due to human error.
  • Enhanced Reporting: the enriched data allows for better tracking of product interactions and conversions, leading to more detailed insights for optimization. Achieving accurate Google shopping conversion tracking is much easier when your product attributes are fully aligned and enriched.

The initial development of this template was done by Lars Friis, and it is now maintained by Stape.

How it works

Google Merchant Center Lookup variable for Google Tag Manager server container
  • Items (input to be enriched)

This is where you specify the item or product data you want to enrich from your Google Merchant Center account. You would typically select an existing variable or data layer property here.

  • Merchant center ID

This is where you input your Google Merchant Center account ID, which the variable will use to look up product information.

  • Cache (hours)

Defines how long the data fetched from the Merchant Center is stored in the cache. For example, if set to 12 hours, the fetched data will be stored for 12 hours before it is updated with new information.

  • Feed language

The language of the product feed that the lookup will pull from. This field ensures that the data matches the correct language of the Merchant Center feed. 

Find parameter in Merchant Center URL: feedLabel=DK

  • Feed label

This allows you to specify which feed within your Merchant Center account to use, particularly if you have multiple feeds for different purposes.

Find parameter in Merchant Center URL: language=da

  • Map product_types into item_categories checkbox

If checked, this option maps the product_type in the Merchant Center to the item_category field in GTM. This can help categorize products in a more structured way for reporting or targeting.

  • Basic Mapping

This allows for simple mappings between Google Merchant Center Lookup variables and GTM variables. You can add rows here to map specific attributes from your Merchant Center to variables in GTM.

  • Custom Mapping

This is for more advanced or complex mappings where you want to manually map specific attributes or variables between the Merchant Center and GTM.

Before starting

Enable the Content API on the GCP project

Google Cloud Platform offers a Content API (Merchant API) for Google Merchant Center. The API allows apps or services to interact directly with a Google Merchant Center account. Enabling the Content API is useful for e-commerce businesses that want to manage products, inventory, and Merchant Center accounts.

To connect the Merchant API/Content API, go to GCP → select the relevant project → type in the search bar Merchant API and select it → on Product details click Enable.

Google Merchant Center Lookup variable for Google Tag Manager server container

Connect the Service Account from the GCP project to Stape

Google Service Account is used to make authorized API requests. By linking a Google Service Account to the server GTM container, you can enable integration between server-side Google Tag Manager and Merchant Center and/or other platforms like BigQuery and Firestore.

The integration allows you to perform different server-side tasks related to your Merchant Center data, including retrieving product information, managing feeds, and sending conversion data.

To connect the Service Account from the GCP project to Stape, create aervice Account in Google Cloud Platform (IAM & Admin → Service Accounts  → Click Create Service Account - If you are unsure what role to use, just pick Project > Viewer) or use an existing Service Account, then go to Stape admin to activate Google Service Account power-up.

For more details on the configuration process check our guide on how to connect Google Service Account to Stape.
Google Merchant Center Lookup variable for Google Tag Manager server container

Add the Service Account as an admin to the Merchant Center account

To do it, go to your Merchant Center account → click the Settings & tools icon in the top right corner → People and access → Click the + Add user button → in the email address field, add the Service account ID. That’s the email of your Service Account; you can find it in the Google Cloud Console. Grant it Admin Access.

How to set up Google Merchant Center Lookup variable

2. Download Google Merchant Center Lookup variable on GitHub or get it from the Template Gallery.

Google Merchant Center Lookup variable for Google Tag Manager server container

3. Import the variable to server Google Tag Manager container by clicking: Templates → New Variable Template. 

Click three dots in the top right corner → Click Import → Add template that you’ve recently downloaded → Click Save.

Google Merchant Center Lookup variable for Google Tag Manager server container

4. Fill in the data in the fields of the variable. Click Save.

And you’re all done!

Google Merchant Center Lookup variable API update

As of August 18, 2026, the Google Merchant Center Lookup variable’s underlying API (Content API for Shopping) has been sunset by Google. The new Merchant API has taken its place. Because of that, we've updated the variable to support only the new Merchant API. Existing users should complete the following required steps to migrate from the old to the new API. 

IAM Service Account Credentials API
Merchant API

2. Register your GCP Project with the Merchant Center account. Learn more about the registration required by the Merchant API, which must be done once per Merchant Center account. 

i

Important: Use your primary Merchant Center account only for this registration, not its sub-accounts. A GCP Project can only be linked to one Merchant Center account, but a Merchant Center account can have multiple GCP Projects registered.  


To register, run the following commands from a terminal or Cloud Shell on your GCP Project. 

2.1. Replace the GCP_PROJECT_ID, MERCHANT_CENTER_ACCOUNT_ID, and SERVICE_ACCOUNT_EMAIL variables below with your actual values, then paste the script below into the terminal or Cloud Shell and run it

i

Important: The SERVICE_ACCOUNT_EMAIL must belong to a Service Account that has Admin access to the Merchant Center account. You can reuse the existing one (recommended) or create a new Service Account, but ensure it has the necessary permissions.  

/

# Replace these with your actual values GCP_PROJECT_ID="your-gcp-project-id" # https://support.google.com/googleapi/answer/7014113?hl=en MERCHANT_CENTER_ACCOUNT_ID="your-merchant-center-account-id" # https://support.google.com/paymentscenter/answer/7163092?hl=en SERVICE_ACCOUNT_EMAIL="your-service-account@your-project.iam.gserviceaccount.com"

2.2. Paste the script below into the terminal or Cloud Shell and run it. Do not modify anything.

# Set your active gcloud project context gcloud config set project ${GCP_PROJECT_ID} # Generate an access token by impersonating the Service Account with the Merchant Center scope. # If this command throws a permission error, ensure your personal user account # has the "Service Account Token Creator" IAM role on the project. ACCESS_TOKEN=$(gcloud auth application-default print-access-token \ --impersonate-service-account="${SERVICE_ACCOUNT_EMAIL}" \ --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/content") # Register the GCP Project with the Merchant Center account curl -X POST \ "https://merchantapi.googleapis.com/accounts/v1/accounts/${MERCHANT_CENTER_ACCOUNT_ID}/developerRegistration:registerGcp" \ -H "Authorization: Bearer ${ACCESS_TOKEN}" \ -H "Content-Type: application/json" \ -d "{}"

2.3. If you get a message like this one, it means that the registration was successful:

{ "name": "accounts/YOUR_MERCHANT_CENTER_ACCOUNT_ID/developerRegistration", "gcpIds": [ "YOUR_GCP_PROJECT_NUMBER" ] }

3. Log in to your GTM account, open the server container, and update the Merchant Center Lookup by Stape variable template. Test it using the GTM Preview. Find out more about debugging and monitoring server-side tracking configuration

4. Publish the changes in the server GTM container once everything is tested.

Conclusion

Google Merchant Center Lookup variable enriches product data in Google Tag Manager by pulling attributes from a Google Merchant Center feed, making it useful for server-side tracking, dynamic remarketing, or other applications where you need detailed product information.

We hope you find this guide helpful and if you have any questions, please feel free to leave a ticket or ask any questions in the comments section.

Interested in server-side?

We are happy to hear that! Click on Try for free to register and check all the possibilities.

Try for free
Ivanna Holubovska

Ivanna Holubovska

Author

Ivanna is a Lead Content Manager at Stape and a certified author on Clutch and KyivPost. She writes high-quality content on server-side tracking to help businesses optimize strategies and analytics.

Comments

Try Stape for all things server-side