Google Tag Manager Installation
Install Ghost Metrics using Google Tag Manager (GTM).
Prerequisites
Before you begin, make sure you have:
- A Google Tag Manager account with access to publish changes
- Your Ghost Metrics tracking code from the dashboard
- GTM container already installed on your website
Step 1: Open Your GTM Container
- Go to tagmanager.google.com
- Select your account and container
- Make sure you’re in the correct workspace
Step 2: Create a New Tag
- Click Tags in the left sidebar
- Click New to create a new tag
- Name your tag “Ghost Metrics” (or something descriptive)
Step 3: Configure the Tag
- Click Tag Configuration
- Select Custom HTML from the tag type list
- Paste your Ghost Metrics tracking code:
<!-- Ghost Metrics Tag Manager -->
<script>
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://example.ghostmetrics.cloud/js/container_XXXXXXXX.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Ghost Metrics Tag Manager -->Replace example.ghostmetrics.cloud and container_XXXXXXXX.js with the values from your Ghost Metrics dashboard.
Step 4: Set Your Trigger
- Click Triggering below the tag configuration
- Select All Pages (or “Initialization - All Pages” for earliest loading)
- Click Save
Which Trigger to Use?
- All Pages — Standard choice, fires when the page loads
- Initialization - All Pages — Fires before other tags, useful if you have many GTM tags
Step 5: Preview and Test
Before publishing:
- Click Preview in the top right
- Enter your website URL
- Navigate through your site in the preview window
- Verify the Ghost Metrics tag fires on each page
You should see your “Ghost Metrics” tag listed as “Fired” in the GTM debug panel.
Step 6: Publish
Once you’ve confirmed the tag is firing:
- Click Submit in the top right
- Add a version name (e.g., “Added Ghost Metrics tracking”)
- Click Publish
Verify in Ghost Metrics
After publishing:
- Visit your website
- Open Ghost Metrics and go to Visitors → Real-time
- You should see your visit appear within seconds
Event Tracking with GTM
You can send custom events to Ghost Metrics via the GTM data layer. Push events like this:
dataLayer.push({
'event': 'ghost_metrics_event',
'eventCategory': 'Form',
'eventAction': 'Submit',
'eventLabel': 'Contact Form'
});Then create a GTM tag that listens for this event and sends it to Ghost Metrics. Contact support if you need help configuring custom event tracking through GTM.
Troubleshooting
Tag Not Firing
- Check that your trigger is set to “All Pages”
- Verify the container is published (not just in preview mode)
- Clear your browser cache and try again
Data Not Appearing in Ghost Metrics
- Confirm the tracking code has the correct domain and container ID
- Check for JavaScript errors in your browser’s developer console
- Verify your GTM container is installed on the website
Next Steps
Last updated on