MGID Server-Side Google Tag Manager Template
Stage 1: Preparation (what the advertiser must do first)
Stage 2: MGID Template Configuration and Installation
Stage 2.1. Page view tag: capture Click ID on arrival
Stage 2.2. Conversion Tag: send conversions back to MGID
Stage 3: Verification (before publishing)
This guide walks your technical or marketing team step-by-step through installing the MGID Server-Side Google Tag Manager (GTM) template into a GTM Server Container. When set up correctly, advertisers get more reliable attribution, improved privacy compliance, and fewer ad-blocking issues.
Stage 1: Preparation (what the advertiser must do first)
Before installing the template, make sure the following are in place:
1. A GTM Server Container (App Engine or Cloud Run) is required to use the MGID server-side GTM template.
Refer to the Tag Manager documentation: Set up a server container
2. Map the Server Container to a same-site subdomain of your website (example: gtm-server.example.com for example.com). Note that cookies set from a different domain will be treated as third-party and blocked.
Refer to the Tag Manager documentation: Map a custom domain
3. Grant publish permission: ensure the person setting up the Server Container also has permission to publish it.
Stage 2: MGID Template Configuration and Installation
Stage 2.1. Page view tag: capture Click ID on arrival
This tag ensures the Click ID is stored immediately upon arrival. To set up the Page view tag, follow these steps:
- In the Server Container, create a New Tag and select MGID Server-Side Tag.
- Set Event Type to PageView.
- Triggering: fire on All Page Views.
- Save as "MGID - PageView".
Stage 2.2. Conversion Tag: send conversions back to MGID
This tag sends the data back to MGID. To set up the Conversion tag, follow these steps:
- In the Server Container, create a New Tag and select MGID Server-Side Tag.
- Set Event Type to Conversion.
- Enter the Event Name (or example purchase). Note: Use only Latin letters, numbers, hyphens, and underscores.
- (Optional) map a Conversion Value.
- Triggering: Fire on your conversion event (e.g., Event Name equals purchase).
- Save as "MGID - Conversion".
Stage 3: Verification (before publishing)
Before you publish, validate the setup in Server Preview:
- In the GTM Server Container, click Preview to open Server Debugger.
- In the browser, simulate page visits and conversion flows (example: visit https://example.com/?adclid=test).
- In Server Debugger:
- Confirm PageView request arrived, and MGID PageView fired.
- Confirm a cookie named MgidSensorClid was set.
- Confirm Conversion request fired and an outgoing request to https://a.mgid.com/postback returned 200.
- Check template console logs for success/error messages (e.g., “Click ID found in page_location”, or “ERROR: Click ID is required…”).
Refer to the Tag Manager documentation: Server-side Preview Mode Guide
For advanced TechOps help or account-specific questions, contact your MGID Account Manager.