Install tracking with Tag Manager
Last updated
Last updated
Create Tag Manager account correspond with your data platform.
Just fill out the form and click Create. If you have an account, you can skip this step and move to step 2.
Install Google Tag Manager script to your platform.
After your account created, you will see Google Tag Manager’s (GTM) installation instruction. Just follow the guide.
If you miss the the instruction, just click the key to reopen it
Config GTM Tag to use DiAnalytics ********Web SDK
Assuming DiAnalytics is installed and DiAnalytics.init(<UNLOCK_CI_DOMAIN>, <API_KEY>)
is called in your platform.
Assuming your website had the script below:
<button onclick="dataLayer.push({event: 'click_save_button', data: ''})">This is a button</button>
Config Custom Trigger
Go to Triggers tab → Select New button → Click on Trigger Configuration
Select Custom
Click on Save with name “Click Save Data”
Config Variables
Built-in variables are default variables, which are provided by GTM. In this case, we show you how to config custom variable
In User-Defined Variables frame, Click on New → Click on Variable Configuration → Select Data Layer Variable
We use ‘data’ to set for Data Layer Variable Name for this example
Click on Save with name ‘Data’
Config GMT Tag with Custom Trigger
Select Add a new tab
Select Tag Configuration
Select Custom HTML
Insert the javascript code into GTM Custom HTML Tag
<script>
window.DiAnalytics.track("click_save_data", { data: {{ Data }} })
</script>
Data
: configured variable at Step 3.2
We use window.DiAnalytics.track
function so that we could track general event info. In addition to, we have already defined details tracking functions. You can use more DiAnalytics’s functions, depending on which functions are needed in your application.
Scroll down and Click on Triggering
Select ‘Click Save Data’ Trigger saved at Step 2.3
Click on Save and Publish
Your setup GTM is successful