Forum Discussion
peterlu
7 days agoChampion
duahire sleslie99 ShannonJ
Here is how I think it will work to implement GTM on Aurora. Please correct me if I am wrong. Below is the Github code level implementation.
Step 1:
under res/pagescripts/, create a folder called "analytics" (res/pagescripts/analytics)
Step 2:
under res/pagescripts/, there should be a file called "groups.scripts.json", edit this file (if not exist, create it),
{
"beforeInteractiveFirst": ["analytics"],
"beforeInteractiveLast": [],
"afterInteractive": [],
"lazyOnLoad": []
}
Step 3:
create "analytics.script.json" under res/pagescripts/analytics/
{
"id": "analytics",
"assets": ["analytics.js"]
}
Step 4:
create "analytics.js" under res/pagescripts/analytics/, replace GTM-XXXXXXXX with your own GTM-ID
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXXX');
Step 5:
Commit and deploy.
Related Content
- 4 months ago
- 2 years ago
- 2 years ago
- 2 years ago