This is a Google Tag Manager Server-Side (s-GTM) Template for Spectacle tracking. It allows you to send data directly from your server container to the Spectacle API, providing enhanced control over data and cookie management, and reducing reliance on client-side scripts.
Features
- Server-Side Tracking: Sends
page, identify, track, and group calls directly from the GTM Server Container.
- Cookie Management: Automatically manages the Spectacle Anonymous ID (
sp__anon_id) and User ID (sp__user_id) cookies for cross-event and cross-request user stitching.
- Full Context Inclusion: Automatically extracts and includes user context like User-Agent, Page/Referrer URL, Campaign UTMs, Timezone, and Locale from the incoming request data.
- Consent Mode Support: Includes a built-in check for
ad_storage consent, allowing you to control tag firing based on the user’s consent status.
- Flexible Configuration: Allows passing custom
User Traits, Group Traits, and Event Properties via a simple table input in the tag configuration.
Installation (Import .tpl)
- Download the Template:
- Download the
template.tpl file from this repository.
- Import to GTM Server Container:
- In your GTM Server Container, navigate to the Templates section.
- Click New under the Tag Templates section.
- Click the three-dot menu in the top right and select Import.
- Select the downloaded
template.tpl file and click Save.
- Create a New Tag:
- Go to Tags and click New.
- Select the newly imported “Spectacle by Stape” tag.
Tag Configuration
When setting up the tag, you will configure it for a specific Spectacle method type (page, identify, track, or group).
1. Base Configuration
| Parameter |
Type |
Required |
Description |
| Spectacle Workspace ID |
Text |
Yes |
Your unique workspace ID (must start with ws_). |
| Method Type |
Select |
Yes |
The type of Spectacle call to make: page, identify, track, or group. |
2. Method-Specific Fields
Based on the Method Type selected, additional fields will be enabled:
Identify Fields
| Parameter |
Type |
Description |
| User ID |
Text |
The unique ID for the user. If provided, it will be stored as a cookie. |
| Email, First Name, Last Name |
Text |
Standard user attributes. |
| Additional User Traits |
Simple Table |
Custom user attributes to send in the traits object. |
Track Fields
| Parameter |
Type |
Required |
Description |
| Event Name |
Text |
Yes |
The name of the event being tracked (e.g., Product Viewed). |
| Revenue (in cents) |
Text |
Optional |
Revenue value associated with the event. |
| Currency |
Text |
Optional |
Currency code (e.g., USD). |
| Event Properties |
Simple Table |
Custom data to send in the properties object. |
|
Group Fields
| Parameter |
Type |
Required |
Description |
| Group ID |
Text |
Yes |
The unique ID for the company/group. |
| Group Traits |
Simple Table |
Custom group attributes to send in the traits object. |
|
3. Advanced Configuration
| Parameter |
Type |
Default |
Description |
| API Base URL |
Text |
https://t.spectaclehq.com |
The Spectacle API endpoint. Must use HTTPS |
| Cookie Domain |
Text |
Empty (auto) |
The domain to use for setting the Spectacle cookies. Leave empty for GTM’s automatic domain detection. |
4. Tag Execution Consent Settings
| Parameter |
Type |
Default |
Description |
| Ad Storage Consent |
Radio |
Send data always |
Required option aborts the tag if ad_storage consent is not given (either via Google Consent Mode or Stape’s Data Tag parameter). |
Open Source
The Spectacle by Stape is developed and maintained by the Stape Team under the Apache 2.0 license.
GTM Gallery Status
Listed
GitHub
Repository
stape-io/spectacle-tag — updated: view commit
- Removed all logging settings and BigQuery log configuration options from the template
- Disabled detailed request and response logging to console and BigQuery
- Simplified logging to only output JSON to console unconditionally
- Removed all code related to logging control, key mappings, and BigQuery integration
- Cleaned up related user and page context data retrieval to use inline calls without variable assignment
GTM Gallery Status
Listed