A Google Tag Manager server-side tag template that forwards events from your server container to an Amperity real-time event stream. Amperity then uses those events for identity resolution and real-time profiles.
The tag sends every event the container receives (for example, from the built-in GA4 client) to:
POST {apiBaseUrl}/prof/events/{streamId}
- All event data, with no fixed field list. The tag reads the full event with
getAllEventData(). - Two renamed fields:
client_idbecomesvisitor_id, andpage_locationbecomespage_url. - Metadata fields:
amp_adapter(gtm-server-container),amp_container_versionandamp_container_id. - Flattened structure: nested objects and arrays become dot-notation keys, for example
items.0.item_id. - No client-side timestamp. Amperity stamps
received_atwhen the event arrives, and that is the canonical event time.
- A GTM server container with a tagging server.
- An Amperity tenant with a real-time event stream. Note its ID, which looks like
esm-.... - An Amperity API key (JWT) that is allowed to write to that stream.
-
In your server container, go to Templates → Tag Templates → Search Gallery and add Amperity Real Time Events Tag.
-
Go to Tags → New, choose the template, and fill in the fields:
Field Description Amperity API Base URL Your Amperity host, for example https://app.amperity.comAmperity Tenant ID Your tenant identifier. Sent as the X-Amperity-Tenantheader.Amperity Event Stream ID The esm-...ID of the target event streamAmperity API Key (JWT) Bearer token for the Streaming Ingest API Enable debug logging Logs event names and response codes in Preview and debug mode only -
Add a trigger. For example, a Custom trigger that fires on all events from the GA4 client.
-
Test in Preview. The tag should report success, and the events should show up in your Amperity event stream.
-
Publish the container.
| Permission | Scope |
|---|---|
| Sends HTTP requests | https://*.amperity.com/prof/events/* only |
| Reads event data | All keys (the tag forwards the full event) |
| Reads container data | Container ID and version, which are added as metadata |
| Logs to console | Debug environment only |
- The API key is sent only from your server container and is never exposed to the browser. Anyone with edit access to the container can still read it in the tag settings, so use a key that is scoped to ingest and can be revoked.
To report bugs or request features, open an issue in this repository. For help with your Amperity setup, contact your Amperity representative or see docs.amperity.com.
Apache 2.0. See LICENSE.