Skip to main content
Google Tag Manager installs the Grain Tag without a change to the code of your website. This page creates one tag, one trigger, and one published version. It takes about 10 minutes.

Before you start

You need three things:
  • Access to your Google Tag Manager account. The container must be installed on your site.
  • Your tenant alias from the dashboard. It is the alias shown at the top of the dashboard, not the UUID.
  • 10 minutes.

1. Create a tag

  1. Log in to Google Tag Manager.
  2. Select your container.
  3. Click Tags, then New.
  4. Click Tag Configuration.
  5. Select Custom HTML.

2. Add the code

Paste this code into the HTML field:
Replace your-tenant-id with your tenant alias.

3. Set the trigger

  1. Scroll to Triggering.
  2. Click the trigger area.
  3. Click + to create a new trigger.
  4. Select Initialization - All Pages.
  5. Name the trigger “All Pages - Initialization”.
  6. Click Save.
The Initialization trigger fires before every other trigger. As a result, the Grain Tag loads early and records every interaction on the page.

4. Name and save the tag

  1. Name the tag “Grain Analytics”.
  2. Click Save.

5. Test the tag

  1. Click Preview (top right).
  2. Enter the URL of your website. Google Tag Manager opens your site with a debug panel.
  3. Make sure that “Grain Analytics” is in Tags Fired.
  4. Open the browser console (F12).
  5. Type window.GrainTag. The console shows the GrainTag object.
If the console shows the GrainTag object, the installation works.

6. Publish

  1. Click Submit (top right).
  2. Name the version, for example “Added Grain Analytics”.
  3. Add a description. This step is optional.
  4. Click Publish.
The Grain Tag is now live on every page of your site. It records page views, clicks, and scroll depth without more configuration. Read Automatic tracking.

Track custom events

After the Grain Tag is installed, you can send an event for a specific user action. Each event is a new Custom HTML tag with its own trigger. {{Click Text}}, {{Click URL}}, and {{Form ID}} are built-in Google Tag Manager variables. Enable them in Variables, then Configure.

Button clicks

  1. Create a new Custom HTML tag.
  2. Add this code:
  1. Set the trigger to All Elements - Click.
  2. Add filters to select the buttons that you want to track.

Form submissions

  1. Create a new Custom HTML tag.
  2. Add this code:
  1. Set the trigger to Form Submission.
  1. Create a new Custom HTML tag.
  2. Add this code:
  1. Set the trigger to Just Links - All Elements.
Read Name events for the naming convention.

Troubleshooting

Read Troubleshooting for cases that are not specific to Google Tag Manager.

Next steps

Trackers

Track clicks on specific elements from the dashboard, without code.

Heatmaps

See where visitors click and how far they scroll.

Tracks

Build funnels and paths from the events that the Grain Tag records.

Privacy and consent

What Grain stores, cookieless mode, and consent modes.