Google Tag Manager (GTM) Integration
This guide covers the GTM setup in Syntropy-Journals and how to use it for managing marketing tags, conversion tracking, and third-party integrations.Overview
Google Tag Manager is installed site-wide via the config-driven head components system. It loads a container (GTM-58ZTSM22) that allows managing tags, triggers, and variables from the GTM dashboard without code deploys.
Architecture
Injection Points
| Tag | Location | Purpose |
|---|---|---|
<script> (GTM container) | <head> | Loads the GTM container and initializes dataLayer |
<noscript><iframe> | <body> via overlay_component | Fallback for JS-disabled browsers |
Configuration
Hydra YAML (config/head/default.yaml)
Environment Variable Override
SetGTM_CONTAINER_ID to use a different container:
Disabling GTM
Setenabled: false in the YAML or provide an empty container ID:
Config Schema
Defined insyntropy_journals/app/config/schemas/head.py:
Active Integrations (Config-Driven)
These integrations are already configured inconfig/head/default.yaml and load automatically on every page.
Apollo.io Website Tracker
Status: Active (inline script inconfig/head/default.yaml)
Apollo visitor tracking is configured as an inline script, not via GTM. It loads on every page and identifies website visitors for sales intelligence.
685cbc612fb8c2001938a965
To verify: open any page, check Network tab for requests to assets.apollo.io, then confirm in Apollo Settings that the connection is active.
Facebook Domain Verification
Status: Active (verification meta tag inconfig/head/default.yaml)
<meta name="facebook-domain-verification" content="29op3ks5j8tpt3jz9mboopn8lr4uj1" />
To verify: visit the published site, view page source, confirm the meta tag is in <head>.
Adding More Tags via GTM
GTM can manage additional marketing/analytics tags without code changes. Configure them in the GTM dashboard.Adding Meta (Facebook) Pixel
- Tags > New > Tag Type: Custom HTML
- Paste the Meta Pixel base code
- Trigger: All Pages
- For conversion events, add additional tags with specific triggers (e.g., form submissions)
Adding LinkedIn Insight Tag
- Tags > New > Tag Type: Custom HTML
- Paste the LinkedIn Insight Tag snippet
- Trigger: All Pages
Adding Hotjar / Microsoft Clarity
- Tags > New > Tag Type: Custom HTML
- Paste the respective tracking snippet
- Trigger: All Pages
DataLayer Events
GTM reads fromwindow.dataLayer. To push custom events from Reflex:
From Client-Side JavaScript
Push events via inline scripts orrx.script:
Common DataLayer Events to Configure
| Event | When | GTM Trigger |
|---|---|---|
page_view | Every page load | Built-in (automatic) |
sign_up | User creates account | Custom Event trigger |
purchase | Stripe checkout completes | Custom Event trigger |
form_submit | Contact/lead form submitted | Form Submission trigger |
Relationship to Other Analytics
| System | Purpose | Config Source |
|---|---|---|
| GTM | Tag management container | config/head/default.yaml (analytics) |
| Google Analytics (GA4) | Page views, sessions, user behavior | config/head/default.yaml (analytics) |
| Apollo.io | Website visitor identification | config/head/default.yaml (inline_scripts) |
| Domain verification | config/head/default.yaml (verification) | |
| PostHog | Product analytics, feature flags | config/integrations/default.yaml |
build_google_analytics_scripts() and does not go through GTM. If you want GA4 managed by GTM instead, disable the standalone GA4 config and add a GA4 tag in GTM.
Verification
Browser DevTools
- Open any page, right-click > Inspect > Elements
- Search for
GTM-58ZTSM22— should appear in both<head>and<body> - Network tab: look for a request to
googletagmanager.com/gtm.js
GTM Tag Assistant
- Install Tag Assistant
- Enter the site URL
- Verify the container loads and tags fire correctly
GTM Preview Mode
- In GTM Dashboard, click Preview
- Enter the site URL
- Browse the site — Tag Assistant shows which tags fired on each page
Files Reference
| File | Role |
|---|---|
syntropy_journals/app/config/head/default.yaml | GTM enabled/container_id config |
syntropy_journals/app/config/schemas/head.py | GoogleTagManagerConfig dataclass |
syntropy_journals/app/utils/head_components.py | build_google_tag_manager_scripts(), build_gtm_noscript() |
syntropy_journals/syntropy_journals.py | Wires GTM into rx.App |
Related Documentation
- Environment Variables — Config system overview
- Architecture — System architecture
- CI/CD — Deployment pipeline