Expand my Community achievements bar.

SOLVED

Where to insert third-party tags/scripts

Avatar

Level 1

I would like to insert the GTM tag in AEM, could someone help me?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

In my response, I am assuming that your AEM pages is using the latest WCM Core Components V2 Page. Also the screenshot provided below is Google's documation on how to install GTM onto your page. https://developers.google.com/tag-platform/tag-manager/web

 

BrianKasingli_0-1640060758964.png

Assuming that your AEM pages is using the latest WCM Core Components V2 Page, I will be placing the GTM code as high as in the head on the page as possible, so I will place the code in line:19 of my overlayed v2 Page Component, (head.html) https://github.com/adobe/aem-core-wcm-components/blob/master/content/src/content/jcr_root/apps/core/...

 

2) I will be placing the next installation code from Google GTM immediately after the closing of the <body> tag, so I will place the code in line:45 of my overlayed v2 Page Component (page.html) https://github.com/adobe/aem-core-wcm-components/blob/master/content/src/content/jcr_root/apps/core/...

 

View solution in original post

2 Replies

Avatar

Community Advisor

Hi @Taise24051991 ,

 

  • GTM <script> part should be inside <head> element. data layer object creation should be before this.
  • <noscript> part should be immediately after the opening of <body> element.

Avatar

Correct answer by
Community Advisor

In my response, I am assuming that your AEM pages is using the latest WCM Core Components V2 Page. Also the screenshot provided below is Google's documation on how to install GTM onto your page. https://developers.google.com/tag-platform/tag-manager/web

 

BrianKasingli_0-1640060758964.png

Assuming that your AEM pages is using the latest WCM Core Components V2 Page, I will be placing the GTM code as high as in the head on the page as possible, so I will place the code in line:19 of my overlayed v2 Page Component, (head.html) https://github.com/adobe/aem-core-wcm-components/blob/master/content/src/content/jcr_root/apps/core/...

 

2) I will be placing the next installation code from Google GTM immediately after the closing of the <body> tag, so I will place the code in line:45 of my overlayed v2 Page Component (page.html) https://github.com/adobe/aem-core-wcm-components/blob/master/content/src/content/jcr_root/apps/core/...