Setting Up Server-Side GTM (sGTM)
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.
You need 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. Trigger: 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 — Influise Conversion, Server Container mode. Download the template from the Integrations page (GTM tab) and import it into your web container. Create a new tag using the template and set Send Mode to Server Container. 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.
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_idmapped to matching dataLayer variables. - This tag must use the GA4 Configuration tag pointing to your sGTM server URL.
Step 3 — sGTM Container: variables
Create these variables. The Constant variable holds your API key and is never sent to the browser.
influise_api_key— Constant — Your Influise API key.click_id— Event Data —click_id.customer_id— Event Data —customer_id.conversion_value— Event Data —conversion_value.payment_id— Event Data —payment_id.
Step 4 — sGTM Container: trigger
Create one Custom Event trigger named influencer_conversion that fires 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
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.
Key notes
- Cookie storage must always happen in the browser — this 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 the sGTM container and never sent to the browser.
- If you are not using GA4, you can send events to sGTM via a direct fetch to your sGTM server endpoint using a custom sGTM client template instead of Step 2.