Event & Custom HTML Tags

7/30/2021

As the name suggests, Google Tag Manager allows you to deploy tags (scripts) to your website. Here are some of the more commonly used tags.

Custom HTML Tags

There are loads of pre-set tags to play around with, but the most commonly used are the Google Analytics tags for events and pageviews, and the Custom HTML tags.

Custom HTML Tags allow you to fire your own script into the header of your site, whether that be CSS, JavaScript etc.
It looks something like this:

Simply input your script, not forgetting to open and close it in the right format like the below examples:

<style> (for CSS) </style>
<script> (for JavaScript etc) <script/>

You can also use variables here, by either typing the whole variable like {{Page URL}} or select from the dropdown after typing in two curly brackets, like this {{

If you have a script that requires document.write(), Google Tag Manager offers an engine for rendering Custom HTML tags. Make sure to tick the Support document.write checkbox.

The Advanced Settings section allows you to adjust the tag firing priority, whether the tag fires per event, per page, or unlimited. You can also set another tag to fire immediately before or after another – this is a feature necessary for setting up tags like Google Optimize.

Event Tags

Here we will run through the setup of a basic external link event as an example to get you started. This will gather information on what external links have been clicked onsite. For this event we will be sending the following to Google Analytics:

  • Category: External Link Clicks
  • Action: {{Click Text}} – this will return the text of the link the user clicked on
  • Label: {{Click URL}} – this will return the URL of the link the user clicked on

Start by creating a new tag - you can do this from the Overview section by clicking New Tag, or from the Tags section by clicking New.

You will then be prompted to name your new tag, choose what type of tag you wish to fire, and either create a new trigger or add an existing trigger.
Rename your tag and click on Tag Configuration to choose your tag type. Select Google Analytics: Universal Analytics from the list and then give it the following information:

  • Track Type: Event
  • Category: External Link Clicks
  • Action: {{Click Text}}
  • Label: {{Click URL}}

It’s a good idea to keep the category as static text, the action and label can be static text or a variable. You can either write in the variable name surrounded by curly brackets, click the icon to open a list of existing variables, or create a new one.

Then select the Google Analytics property you wish to send this event to. Now you are ready to add your trigger.