Guides
Google Tag Manager
Integrate Alytica with Google Tag Manager.
Prerequisites
- An Alytica account
- Client ID (and optional Client Secret)
- Access to Google Tag Manager
- A container set up for your website
Step 1: Create Custom HTML Tag
- Log in to Google Tag Manager
- Navigate to Tags > New
- Select "Custom HTML" as the tag type
- Paste the following code into the HTML field:
Step 2: Configure Trigger
- In the same tag configuration, click on "Triggering"
- Select "All Pages" to track every page of your website
- Alternatively, create custom triggers for specific pages
Step 3: Create Variables (Optional)
For better management:
- Go to Variables > New > User-Defined Variables
- Create a Constant variable named "Alytica Client ID"
- Enter your client ID value
- Update your tag to use
{{Alytica Client ID}}
instead of hardcoding
Step 4: Track Custom Events
Option 1: Custom HTML Tags
Create additional Custom HTML tags for specific events:
Option 2: Custom Event Tag
- Create a new Custom HTML tag
- Use Data Layer variables to pass event data
- Set appropriate triggers (e.g., click triggers, form submissions)
Step 5: User Identification
Create a Custom HTML tag for identifying logged-in users:
Step 6: Preview and Publish
- Click "Preview" to test your implementation
- Verify events are firing correctly in Preview mode
- Check browser console for any errors
- Submit and publish your changes when everything works correctly
Advanced GTM Configuration
Data Layer Integration
Push events to the Data Layer and create tags that respond to them:
Then create a Custom HTML tag triggered by the 'alytica_event' Data Layer event:
Troubleshooting
- Use GTM's Preview mode to debug tag firing
- Check browser console for JavaScript errors
- Verify Alytica events in your Alytica dashboard
- Test different trigger conditions if events aren't firing