Article

S2S – GTM

With Google Tag Manager, Server-to-Server goes through two containers: your web container (client-side) sends page views and the purchase to your server-side container, where the Affilae – Server Side tag sends the conversion to Affilae.

This page covers the setup of both containers.

Prerequisites: the URL format of your program must be set to Server-to-Server (S2S). You change it in Programs > [your program] > Configuration, section Global settings, field URL format. You also need a working server-side container and its domain, plus your Affilae key.
Warning: never send personal data, for example a first name, a last name or an email address. Implementing a CMP remains mandatory.
Note: the Affilae – Server Side tag must fire on two events: page views (All Pages) and the purchase (Purchase). Without page views, the click ID is never stored.

Required architecture

You must have 2 GTM containers:

  • a Client-Side container (your web container);
  • a Server-Side container.

The web container sends its events to the server-side container.

Client-Side configuration

Create the Google tag to the Server-Side

In your Client-Side container:

  1. Go to Tags > New, then name the tag.
  2. Tag type: Google Tag.
  3. Tag ID: your Google Analytics 4 measurement ID, in the G-XXXXXXX format.
  4. Configuration settings: the variable holding the address of your server-side container (see below).
  5. Triggering: Initialization – All Pages.

Configure the server address

  1. Go to Variables > New.
  2. Variable type: Google Tag: Configuration Settings.
  3. Config parameter: server_container_url.
  4. Value: the address of your server-side container, for example https://sgtm.yoursite.com/.

Send the purchase

Your web container must also send the GA4 purchase event to the server-side container, with its transaction_id, value, currency parameters and, when a promo code is used, coupon. If your GA4 events already go through that container, there is nothing to add.

Save and publish the container.

Server-Side configuration

Create the Affilae Server-Side tag

In your Server-Side container:

  1. Go to Tags > New, then name the tag.
  2. As the tag type, search for Affilae – Server Side.
  3. If the type is not available, import the template from the gallery.

Create the variables

Create them in Variables > New. The names are examples.

  • affilae_key: type Constant, value = your Affilae key, found in Configuration > tab Tracking.
  • conversion_id: type Event Data, key transaction_id. This is the order number, unique for each order.
  • conversion_amount: type Event Data, key value, if that value is the amount excluding tax, after discounts and without shipping costs. Otherwise, send that amount in another event parameter and read that one.
  • conversion_voucher: type Event Data, key coupon. Separate several codes with a semicolon.

Fill in the Affilae tag

  • Event Name: purchase by default. Change it if your purchase event has another name.
  • Tracking Key: {{affilae_key}}
  • Conversion ID: {{conversion_id}}, required.
  • Conversion Total Excl. VAT: {{conversion_amount}}
  • Currency Code: EUR, or a variable reading the currency parameter.
  • Voucher Codes: {{conversion_voucher}}, optional.
  • Customer Id, Product Ids and Conversion SubId: optional, with the same values as the conversion tag parameters described in C2S – Manual.
  • Conversion Payment Method: online by default.
Allow Probabilistic Attribution: ticked by default. Ticked, the tag sends every purchase to Affilae, even without a stored click ID, and Affilae then attempts a session match. Unticked, only purchases carrying a click ID or a promo code are sent.

The triggers

The Affilae – Server Side tag has two triggers:

  • All Pages (page view): the tag reads the aecid click ID in the landing page address and keeps it for 30 days in an HttpOnly cookie set on your domain.
  • Purchase: the tag sends the conversion to Affilae with that click ID.

How the two containers communicate

  1. The web container sends every page view and the purchase to the server-side container.
  2. On a page view, the Affilae tag stores the click ID found in the address.
  3. On the purchase, it sends the conversion to Affilae with the order number, the amount, the currency and the click ID.

To verify the link, enable Preview mode on both containers, test a full journey, and check that the page_view and purchase events reach the server-side container.

Pre-launch checklist

  • Affilae program set to S2S mode.
  • Server-Side container functional.
  • Google Tag configured with server_container_url.
  • purchase event sent to the server-side container.
  • Server-Side variables created.
  • Affilae – Server Side tag configured, Conversion ID included.
  • All Pages and Purchase triggers on the Affilae tag.

Tests to perform

  1. Disable your ad blockers.
  2. Enable GTM Preview mode on both containers.
  3. Test an affiliate click followed by a conversion.
  4. Check that data is transmitted between the containers.
  5. Check that the conversion is recorded in Affilae, with the right amount and currency.
Tip: keep both preview modes open side by side during your test. You then see immediately whether the problem sits in the client-side container, which sends nothing, or in the server-side container, which receives but does not forward.

The other Google Tag Manager integrations

Related articles

Frequently asked
questions

See more questions

Yes. The Affilae – Server Side tag runs in a server-side container, which receives the page views and the purchase sent by your web container.

Your Google Analytics 4 measurement ID, in the G-XXXXXXX format. The address of your server-side container goes into the server_container_url configuration parameter.

In the preview mode of the server-side container, check that the page_view and purchase events arrive. Then check the two triggers of the Affilae tag, the Conversion ID field and the S2S mode of the program, and run a test with a real order.

Ticked, which is the default, the tag sends every purchase to Affilae, even without a stored click ID, and Affilae then attempts a session match. Unticked, only purchases carrying a click ID or a promo code are sent.

Import the template from the Community Template Gallery, then start creating your tag again. The type becomes selectable in the list.

Yes. Implementing a CMP remains mandatory, whatever tracking mode you choose.

This integration does not work. Set the URL format to Server-to-Server (S2S) in Configuration, section Global settings. That setting is what switches your tracking links to redirection and allows server-side validation.

Need help?

Stay up to date with the latest trends in affiliate marketing and never miss any of our articles.

Contact Us