---
updatedAt: 2025-06-17T21:38:09.000Z
agentTools:
  projectIndex: https://support.kissmetrics.io/llms.txt
---

# Installing Kissmetrics through GTM

[Google Tag Manager](https://www.google.com/tagmanager) is a free tag management system. Rather than editing site code every time you want to add HTML/JavaScript snippets, you can install the Tag Manager script *once* and make updates from within Google.

The concept is similar to creating events with our [Event Manager](https://support.kissmetrics.io/docs/event-manager) , where you install our main piece of JavaScript *once* and manage your events within [Kissmetrics](https://app.kissmetrics.io/event_manager).

> 🚧
>
> ***In case you have an existing GTM implementation, please skip to[step 3](https://support.kissmetrics.io/docs/installing-kissmetrics-through-google-tag-manager#step-3-back-in-google-tag-manager-set-up-a-tag-for-the-kissmetrics-javascript-snippet).***

## Step 1: Get Started

Set up your account at the [Google Tag Manager website](https://www.google.com/tagmanager). You’ll be asked to create a "container", which is a collection of tags for a website. Then you’ll get these pieces of code with the instructions for instalment:

<Image alt="GTM snippets" align="center" src="https://files.readme.io/7756484-01_GTM_script.png">
  GTM snippets
</Image>

## Step 2: Install the Google Tag Manager Code on your website

Make sure the provided Google Tag Manager scripts are placed on ***every page of your site.***

For example, you can store the snippets in one file and add these files later on to the main header html or main route file that would load the snippet to all the pages of your website or web application.

## Step 3: Back in Google Tag Manager, Set Up a Tag for the Kissmetrics JavaScript Snippet

Back in Google Tag Manager, you would need to create a **"Custom HTML Tag"**, in order to add your Kissmetrics JavaScript Snippet.

* Start with adding a new **Tag**;

<Image alt="\+New Tag" align="center" src="https://files.readme.io/cfddf2b-02_creating_new_gtm_tag.png">
  \+New Tag
</Image>

* Add your **Tag Name** and click to select the proper **Tag Configuration**;

<Image alt="Tag Name + Tag Configuration" align="center" src="https://files.readme.io/97c8ee7-03_tag_name_tag_configuration.png">
  Tag Name + Tag Configuration
</Image>

* Scroll down the tag configuration list and click to add **"Custom HTML"**;

<Image alt="Custom HTML Tag Type" align="center" src="https://files.readme.io/d67669a-04_custom_html_tag.png">
  Custom HTML Tag Type
</Image>

* In the new browser tab, please refer to your site’s [Product settings page](https://app.kissmetrics.io/settings) to obtain your Kissmetrics JavaScript snippet, which you’ll place in the "HTML" field;
* In the Google Tab Manager tab, paste the Kissmetrics JavaScript snippet;

<Image alt="Kissmetrics JS Snippet" align="center" src="https://files.readme.io/2da5943-05_adding_KM_JS_snippet.png">
  Kissmetrics JS Snippet
</Image>

* From there, you need to add a **Trigger** that would specify the rules for the **Tag** to fire. For that, scroll down the above page and click on the **Trigger** section;

<Image alt="Adding New Trigger" align="center" src="https://files.readme.io/4a4ed9d-06_adding_trigger_for_KMJS.png">
  Adding New Trigger
</Image>

* Inside the Trigger configuration, click to select **All Pages**, so that you can tell Google Tag Manager where to load our snippet on;

<Image alt="All Pages Trigger" align="center" src="https://files.readme.io/a4dd365-07_all_pages_trigger.png">
  All Pages Trigger
</Image>

* Save this tag.

<Image alt="Saving the tag" align="center" src="https://files.readme.io/293d0b6-08_save_tag.png">
  Saving the tag
</Image>

## Step 4: Add Additional JavaScript for Custom Events

If you’d like, you can define custom Kissmetrics events by adding more tags to the container. In the next example, we’ll create a trigger to record the "Viewed GTM page" event when people go to the URL path /gtm\_testing.

* Add a new **Custom HTML Tag**;

<Image alt="New Custom HTML Tag" align="center" src="https://files.readme.io/50e3aeb-09_new_event_tag.png">
  New Custom HTML Tag
</Image>

> 👍
>
> Notice the presence of `var _kmq = _kmq || [];`. This is necessary because Google Tag Manager [doesn’t let you control the order](http://support.google.com/tagmanager/answer/2772421/?hl=en) in which your tags are loaded. *Without adding this line above your JavaScript for custom events, you may end up with JavaScript errors.*

* Define a new **Page View Trigger** for your tag;

<Image alt="\+New Trigger" align="center" src="https://files.readme.io/5c9f2dc-10_new_page_view_trigger.png">
  \+New Trigger
</Image>

<Image alt="Trigger Name and Trigger Type" align="center" src="https://files.readme.io/b38f38c-11_trigger_configuration.png">
  Trigger Name and Trigger Type
</Image>

<Image alt="Add the trigger conditions and hit save " align="center" src="https://files.readme.io/e1a7afd-12_trigger_conditions.png">
  Add the trigger conditions and hit save 
</Image>

* Save the tag

<Image alt="Save tag with the new trigger" align="center" src="https://files.readme.io/a0b0b21-13_save_tag_and_trigger.png">
  Save tag with the new trigger
</Image>

## Step 5: Create a Container Version and Publish

After creating the tags, it is key to **Submit** and **Publish** the changes before testing.

* **Tags** section;

<Image alt="All tags view" align="center" src="https://files.readme.io/79639fe-14_tags_section.png">
  All tags view
</Image>

* click **"Submit"**;

<Image alt="Submitting changes" align="center" src="https://files.readme.io/87c5122-15_submit_the_changes.png">
  Submitting changes
</Image>

* Add the **Version Name** and **Publish** the changes;

<Image alt="Publishing changes" align="center" src="https://files.readme.io/099ae30-16_publishing_changes.png">
  Publishing changes
</Image>

## Step 6: Troubleshoot the setup

As always, you can check in [Kissmetrics Live](https://support.kissmetrics.io/docs/live) to look for your own activity, and to check that you’ve installed properly.

<Image alt="Live View test" align="center" src="https://files.readme.io/73de0a5-17_live_view_test.png">
  Live View test
</Image>

## That’s It!

> 👍 To recap, there are 4 steps:
>
> 1. Create **a tag** containing the JavaScript snippet and/or API calls.
> 2. Create **a trigger** that tells on which pages to load those tags.
> 3. Create **a version** to save a history of your changes.
> 4. **Publish** the version so that it is actively running on your site.