Expand my Community achievements bar.

SOLVED

Adding GTM on AEM authoring environment

Avatar

Level 4

Hi All,

Could you please let me know the steps to implement the google analytics on AEM authoring environment with GTM script  which can track all events on AEM. Kindly let me know your thoughts. Also, please let me know any common file on AEM to configure GA.

 

Thanks in Advance! 

1 Accepted Solution

Avatar

Correct answer by
Employee

EDIT: I just realized you werent asking about AEM Sites .. im in the Assets community afterall!! 

 

There isn't a natural hook to at GTM to the AEM Assets *authoring* experience. I think you would have to either:

 

1) Try to find all an OOTB clientlib category that is loaded "everywhere" in the authoring experience, make your own clientlib w/ a JS that includes your GTM snippet, and mark that clientlib with that ubiquitous clientlib category. That way your GTM would get pulled in whenever the product pulls in that clientlib. That said, its hard to tell where in the page load lifecycle that would get pulled in.

 

2) I believe you could write a Sling Pipeline Transformer that injects your GTM script tag into the <head> tag, though i've never tried this before (ive only ever modified  attributes of existing HTML elements)

 

3) Technically you could write a Sling Filter that injects this on all HTML requests, but this has a number of downsides and is quite intrusive.

 

Long and short is there isn't a good pattern to do this.

 

 

--- 

ORIGINAL RESPONSE ->  The following would be for an AEM Sites web site

Is there any reason you can't use Adobe Launch to include Google Analytics extension? If that is possible, that is recommended since AEM + Launch integration is OOTB.

 

If you cannot, then I would overlay your base page components' /apps/my-site/components/.../page.../customheaderlibs.html and add your GTM tag in there.

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

EDIT: I just realized you werent asking about AEM Sites .. im in the Assets community afterall!! 

 

There isn't a natural hook to at GTM to the AEM Assets *authoring* experience. I think you would have to either:

 

1) Try to find all an OOTB clientlib category that is loaded "everywhere" in the authoring experience, make your own clientlib w/ a JS that includes your GTM snippet, and mark that clientlib with that ubiquitous clientlib category. That way your GTM would get pulled in whenever the product pulls in that clientlib. That said, its hard to tell where in the page load lifecycle that would get pulled in.

 

2) I believe you could write a Sling Pipeline Transformer that injects your GTM script tag into the <head> tag, though i've never tried this before (ive only ever modified  attributes of existing HTML elements)

 

3) Technically you could write a Sling Filter that injects this on all HTML requests, but this has a number of downsides and is quite intrusive.

 

Long and short is there isn't a good pattern to do this.

 

 

--- 

ORIGINAL RESPONSE ->  The following would be for an AEM Sites web site

Is there any reason you can't use Adobe Launch to include Google Analytics extension? If that is possible, that is recommended since AEM + Launch integration is OOTB.

 

If you cannot, then I would overlay your base page components' /apps/my-site/components/.../page.../customheaderlibs.html and add your GTM tag in there.