Setting up Analytics with GTM
This article covers how to set up Google Tag Managerย to collect and organize data on how users interact with your Airkit apps.
Prerequisites
- Access to aย Google Tag Manager account, container, and container ID.
- Passing familiarity with how to set up tags and triggers within Tag Manager. (To learn more about tags, triggers, and collecting data within Tag Manager, check outย their documentation site.)
Declare Google Tags Manager the analytics provider of your app
Setting up Tags Manager so that it can begin handling the analytics of your website begins by installing the Tags Manager and declaring what container your data will be associated with. (Outside of Airkit, this is often done by inserting code into the relevant web pages, see documentation here.) This is done via the following steps:
-
Open the app that you want to associate with Tag Manager in the Studio.
-
Toggle down to the Settings and scroll down to the Analytics section.
-
Under Provider, select "Google Tag Manager".
-
Under ID, enter your Tag Manager container ID, which should be in the formatย
GTM-XXXXXX
. (The container ID defines the container within Tag Manager that will store analytics related to this app. The containers accessible to you as well as their associated IDs should be visible upon visiting Google's Tag Manager home page; their documentation also describes how to find and utilize your container IDs.)
Upon completion, the Analytics section of Settings should look as follows, with the "X"s under ID replaced with the value of your own Tag Manger container ID:
Save your changes. Installation of Tag Manager is now complete and includes the creation and installation of the optional data layer object.ย
Log Page Views
Once Tag Manager is installed and the application is published, Airkit will automatically send a custom page tracking event to the data layer every time a user navigates to another Web Flow or Web Page.ย This custom page tracking event is sent in a JSON object with the following format, where Web_Flowย and Web_Page correspond to the names of the Web Flow and Web Page (respectively) that the user just navigated to:
{
"event": "Page Navigate",
"properties": {
"Page-Name": Web_Flow,
"View-Name": Web_Page
}
}
While this custom page tracking event will automatically be sent to the data layer, a tag and custom event trigger must be set up so that the sent information can be properly parsed. To read more about triggers and custom events within Tag Manager, click here.ย
Send Custom Events
In addition to automatically sending aย custom page tracking event to the data layer every time a user navigates to another Web Page, Airkit also provides the tools to send a custom payload at any time, using the Analytics Send Event Action, which will send a JSON object in the following format:
{
"event": Event_Name,
"properties": Event_Properties
}
Event_Name and Event_Properties correspond to values entered in the Analytics Send Event Actionย under "Event Name" and "Event Properties", respectively.
As with logging page views, a a tag and custom event trigger must be set up so that the sent information can be properly parsed. To read more about triggers and custom events within Tag Manager, click here.
Updated almost 2 years ago