S2S – GTM
Discover the most-read articles
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.
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:
- Go to Tags > New, then name the tag.
- Tag type: Google Tag.
- Tag ID: your Google Analytics 4 measurement ID, in the G-XXXXXXX format.
- Configuration settings: the variable holding the address of your server-side container (see below).
- Triggering: Initialization – All Pages.
Configure the server address
- Go to Variables > New.
- Variable type: Google Tag: Configuration Settings.
- Config parameter: server_container_url.
- 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:
- Go to Tags > New, then name the tag.
- As the tag type, search for Affilae – Server Side.
- 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.
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
- The web container sends every page view and the purchase to the server-side container.
- On a page view, the Affilae tag stores the click ID found in the address.
- 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
- Disable your ad blockers.
- Enable GTM Preview mode on both containers.
- Test an affiliate click followed by a conversion.
- Check that data is transmitted between the containers.
- Check that the conversion is recorded in Affilae, with the right amount and currency.
The other Google Tag Manager integrations
- C2S – GTM – Templates: client-side tracking with the two Affilae templates from the GTM gallery.
- C2S – GTM – Manual: client-side tracking with your scripts pasted into Custom HTML tags.
Related articles
- S2S – Server-to-Server
- Affilae tracking fundamentals
- Testing click and conversion tracking
- Frequently asked questions, technical integration
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.
