Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Injecting JS Code on AEM Web Pages for Analytics Integration

Avatar

Level 10

Hi all,

If we need to Inject JS Code on AEM Web Pages for Analytics Integration, do we do it on templates or components or both?

I agree that DTM is a good tool for this.

Even if we use DTM, where will it inject?

If we are able to do it only on templates, the effort will be less.

Appreciate all your responses.

Thanks,

Rama.

1 Accepted Solution

Avatar

Correct answer by
Administrator

DTM Way (Recommended way)

Please have a look at my previous reply, I stated it clearly that its the Page where we inject the code by adding could service to the Base page.

"It is always recommended to it at webpage level by going through page property->could service-> select DTM connector"

NON DTM

If it is not with DTM then you can add any script to AEM page in a way with which we add JavaScript normally to the page.

Using DTM for this case is easy, manageable and can be done without knowing the code information.Also, the user could run various kind of rules and make the best use of AEM context hub and custom data layer. This is the main ideology kept in mind so that marketer can configure any analytics JS or third-party JS in a web page.

And if you would like to connect AEM with third party Analytics then this connector could also be used:- Analytics with External Providers

~kautuk



Kautuk Sahni

View solution in original post

6 Replies

Avatar

Level 10

See this cross solution article - it will point you in the correct direction -- Adobe Experience Manager Help | Integrating Adobe Experience Manager with Adobe Analytics and Target...

Also - here is Ask the AEM Commuity Experts on AEM and Analytics that will help you too -- ATACE March 28 2017

Avatar

Administrator

Hi,

I highly recommend you to do hands-on this integration:- Adobe Experience Manager Help | Integrating Adobe Experience Manager with Adobe Analytics and Target...

This will help you clear many of your doubts. In AEM we create a web page using the template and within that web page's template, we add components. It does not make any sense of adding Analytics JS at the component level. Same it is not good to do on template level. Maybe 2 different web pages on the same template need to have different analytics implementation. so, in this case, we can use different DTM cloud service.

It is always recommended to it at web page level by going through page property->could service-> select DTM connector.

I hope this answers your question.

~kautuk



Kautuk Sahni

Avatar

Level 10

Thanks Kautuk for this detailed response.

1. Let us consider not using DTM.

If Templates is not answer and components is also not answer, what is the correct answer?

Mix and match?

2. Where does DTM insert?

I have been through both these videos. Neither of them addresses this question.

Appreciate your responses.

Thanks,

Rama.

Avatar

Level 10

As using DTM is best practice - we recommend using this. Why are you not using this approach?

Avatar

Correct answer by
Administrator

DTM Way (Recommended way)

Please have a look at my previous reply, I stated it clearly that its the Page where we inject the code by adding could service to the Base page.

"It is always recommended to it at webpage level by going through page property->could service-> select DTM connector"

NON DTM

If it is not with DTM then you can add any script to AEM page in a way with which we add JavaScript normally to the page.

Using DTM for this case is easy, manageable and can be done without knowing the code information.Also, the user could run various kind of rules and make the best use of AEM context hub and custom data layer. This is the main ideology kept in mind so that marketer can configure any analytics JS or third-party JS in a web page.

And if you would like to connect AEM with third party Analytics then this connector could also be used:- Analytics with External Providers

~kautuk



Kautuk Sahni

Avatar

Community Advisor

We have DTM integrated for our projects. I would recommend to add the script in templates level. There will be one JS which will pull all the scripts from DTM. So the best thing you can do if you are using DTM is to insert it to the templates.