For the complete documentation index, see llms.txt. This page is also available as Markdown.

WooCommerce

How to set up server-side tagging for a WooCommerce webshop


Setting up server-side tagging for WooCommerce

This article walks you through the full setup of server-side tagging on a WooCommerce store: generating your Google Tag Manager templates, importing them, filling in your IDs, testing them, and finally removing the old tracking connections within the WooCommerce webshop.

Before you start

This article picks up where Getting Started leaves off. Make sure all of the steps in the Setup AdPage container article have been followed. Which means that:


Multilingual environments (WPML)

Step 1: Generate your templates in the Template Library

You do not have to build your tags, triggers and variables by hand. AdPage's Template Library generates a complete, tested Google Tag Manager setup for WooCommerce for you.

  1. Select the marketing platforms you want to send data to, for example Google Ads, Meta Ads, TikTok Ads, LinkedIn Ads or Pinterest Ads.

  2. Select the Consent Management Platform you use on your WooCommerce webshop.

  3. Generate the templates. You get two JSON files: one for your GTM web container and one for your GTM server container.

  4. Download both files and keep them handy.

Only select the platforms you actually use. Every platform you add creates extra tags and constant variables that you will need to fill in later.


Step 2: Import the web container template

  1. Open your GTM web container.

  2. Go to Admin and click Import Container.

  3. Select the web JSON file you downloaded.

  4. Choose a workspace.

    • If you have unpublished changes in your default workspace, we recommend importing into a new workspace so your import stays separate from any other work in progress.

  5. Choose the import option:

    • Merge and rename conflicting tags, triggers and variables for a container that already contains a setup. Nothing existing gets removed.

    • Overwrite only for a brand new, empty container.

  6. Check the preview of the changes that GTM shows you, then click Confirm.


Step 3: Import the server container template

Repeat the same steps in your GTM server container with the server JSON file.

  1. Open your GTM server container.

  2. Go to Admin and click Import Container.

  3. Select the server JSON file.

  4. Import into a new workspace and choose Merge and rename conflicting tags, triggers and variables.

  5. Check the preview and click Confirm.

  6. Go to Clients and check if an extra GA4 client has been set up. If so, delete the imported GA4 client.


Step 4: Fill in the constant variables

Both templates are built around constant variables. All IDs, tokens and settings live in one place, so you never have to open individual tags to change something.

  1. In your GTM web container, go to Variables.

  2. Open every constant variable, which you can recognize by the "@" in the name. Fill in the correct value per variable. See the table below to know what ID or Token you have to fill in.

  3. Save each variable.

  4. In your GTM server container, go to Variables.

  5. Open every constant variable, which you can recognize by the "@" in the name. Fill in the correct value per variable. See the table below to know what ID or Token you have to fill in.

  6. Save each variable.

Depending on the platforms you selected, you will typically fill in:

Container
Variable
Value

Web

Server Container URL

The tagging domain from your CNAME record, for example: https://tagging.domain.com

Web

GA4 Measurement ID

Your GA4 property's Measurement ID: G-XXXXXXXXXX

Web

Meta Pixel ID

Your Pixel ID from Meta Events Manager

Web

TikTok Pixel ID

Your Pixel ID from TikTok Events Manager

Web

Pinterest Tag ID

Your Pinterest Tag ID, found in the Tag Manager of your Pinterest Ads Account

Web

LinkedIn Partner ID

Your LinkedIn Partner ID, found in the Signals Manager of your LinkedIn Ads Account

Web

Cookiebot Domain Group ID

The Domain Group ID from your Cookiebot account

Server

GA4 Measurement ID

Your GA4 property's Measurement ID: G-XXXXXXXXXX

Server

Meta Pixel ID

Your Pixel ID from Meta Events Manager

Server

Meta API Ttoken

The API Token of your Pixel from Meta Events Manager

Server

TikTok Pixel ID

Your Pixel ID from TikTok Events Manager

Server

TikTok API Token

The API Token of your Pixel from TikTok Events Manager

Server

Google Ads Conversion ID

Your Google Ads Conversion ID: AW-XXXXXXXXXX minus the AW- part

Server

Google Ads Conversion Labels

Create new purchase, add_to_cart, and begin_checkout conversions in Google Ads. Once set up, you can find their Conversion Labels.

Server

Pinterest Advertiser ID

The Advertiser ID from your Ad Account. This ID usually starts with 549.

Server

Pinterest API Token

The API Token found in your Conversions API settings of your Pinterest Business Account.

Server

LinkedIn API Token

The API Token which you can generate in your LinkedIn Campaign Manager in the Sources.

Server

LinkedIn Conversion IDs

Create new purchase, add_to_cart, and begin_checkout conversions in LinkedIn Ads. Once set up, you can find their Conversion IDs in the URL of the conversion.

Never leave a constant variable empty. An empty ID means tags fire without a destination, which shows up as missing conversions or failed outgoing requests later on.


Step 5: Test in preview mode

You have just imported container templates with complete tracking for GA4 and the marketing platforms you selected. That means everything you need is now present in your GTM containers, and anything that was already there for the same purpose is a duplicate.

Disable your old tags first

Go through the tags in your web container and pause or delete every tag that measures something your new setup now handles. In practice this is your old GA4 configuration tag, all GA4 event tags for e-commerce steps such as add_to_cart and purchase, your Meta Pixel tags, your Google Ads remarketing tags, and any custom HTML tags that send data to a platform directly.

If you are not sure whether you will need an old tag later, pause it instead of deleting it. You can always remove it in a later version once the new setup has proven itself. Old triggers and variables can stay, they do nothing on their own.

Skip this and preview mode will show two of everything, and after publishing your conversions will be counted twice.

Test both containers

  1. Open the Preview mode in your GTM web container and fill in the URL of your webshop.

  2. Open the Preview mode in your GTM server container as well, so you can follow the same hits arriving server-side.

  3. Walk through the complete customer journey and check that each step fires once, with the right e-commerce parameters:

    • page_view

    • view_item_list

    • view_item

    • add_to_cart

    • view_cart

    • remove_from_cart

    • begin_checkout

    • add_shipping_info

    • add_payment_info

    • purchase

  4. For every event, check in the server container that the GA4 event request arrives and that your platform tags fire and return a successful response.


Step 6: Clean up and publish

Before you publish, make sure your WooCommerce site no longer loads the tracking scripts that now run through your server container. If you set up Meta Ads through server-side tagging, the Meta Pixel base code has to go. The same applies to a gtag.js snippet for GA4 or Google Ads, a TikTok pixel, a Pinterest tag, or any other pixel that is now fired from the server container. Check your theme files, your child theme's functions.php, any header or footer script fields, and the plugins you use, because pixels are often injected by a marketing or conversion plugin rather than by hand.

Also remove the standard GTM snippet if it is still present anywhere. The AdPage plugin loads the connection to the GTM web container itself, so a second snippet means script loading issues.

Once that is done, publish your web and server container. Use a version name and description you will recognise later, for example "AdPage server-side tagging", so you can roll back to the previous version if something turns out to be wrong.

Finish with a test purchase on your live site and check in the AdPage interface and the GA4 realtime report whether the events arrive and the conversions are registered once. Any connection that WooCommerce still maintains directly with an advertising platform will send the same event a second time, which leads to duplicated conversions and inflated revenue in your reports.


Need help?

Still seeing missing events, duplicated conversions or unassigned traffic after following these steps? Reach out to our support team and we will take a look with you.

Last updated

Was this helpful?