Server-Side GTM (sGTM) Setup
Updated August 5, 2026
Why Use sGTM
In a server-side GTM setup the web container no longer calls the Influise API directly. Instead it pushes events to the dataLayer; the sGTM server container picks them up and makes the API calls — keeping your API key completely off the browser and out of reach of ad blockers.
Prerequisites: an sGTM server container deployed (e.g. via Google Cloud Run or Stape.io) with a GA4 property connected through it. The web container's GA4 Configuration tag must point to your sGTM server URL — not directly to Google Analytics.
Step 1 — Web Container: 2 Tags
Tag 1 (Custom HTML) stores the click ID cookie on All Page Views:
(function() { var clid = new URLSearchParams(window.location.search).get('clid'); if (clid) document.cookie = 'influise_clid=' + encodeURIComponent(clid) + '; path=/; max-age=31536000; SameSite=Lax'; })();
Tag 2 uses the Influise Conversion template in Server Container mode. Download the template from the Integrations page, import it into your web container, and create a tag with Send Mode set to Server Container — push to dataLayer for sGTM. Supply Customer ID (and optionally Conversion Value and Payment ID) as GTM variables — the click ID is read from the cookie automatically. No API key required here.
Step 2 — Web Container: GA4 Event Tag
Create one GA4 Event tag to forward the influencer_conversion dataLayer event to your sGTM server.
- Trigger: Custom Event —
influencer_conversion - Parameters:
click_id,customer_id,conversion_value,payment_id→ matching dataLayer variables
This tag must use the GA4 Configuration tag pointing to your sGTM server URL.
Step 3 — sGTM Container: Variables
influise_api_key— Constant — your Influise API keyclick_id— Event Data —click_idcustomer_id— Event Data —customer_idconversion_value— Event Data —conversion_valuepayment_id— Event Data —payment_id
Step 4 — sGTM Container: Trigger
Create one Custom Event trigger named influencer_conversion to fire the conversion HTTP Request tag. Clicks are recorded server-side by the tracking link redirect — no click trigger is needed in sGTM.
Step 5 — sGTM Container: 1 HTTP Request Tag
Influise — Conversion (Trigger: influencer_conversion)
- URL:
https://app.influise.com/api/conversion - Method: POST
- Headers:
Content-Type: application/json,X-API-Key: {{influise_api_key}} - Body:
{ "customerId": "{{customer_id}}", "conversionValue": {{conversion_value}}, "clickId": "{{click_id}}", "paymentId": "{{payment_id}}" }
The API uses clickId when present. When absent, it falls back to looking up the original influencer from the customer's first conversion using customerId + paymentId.
Important Notes
- Cookie storage must always happen in the browser — it cannot be moved server-side.
- Clicks are recorded by the tracking link redirect, not by GTM, so they are never blocked by ad blockers.
- The API key is stored as a Constant variable in sGTM and never sent to the browser.
- The web container's GA4 Configuration tag must point to your sGTM server URL.
- If you are not using GA4, send events to sGTM via a direct fetch to your sGTM server endpoint using a custom sGTM client template instead of Step 2.