How Insert Google Analytics snipper on different pages

michelem2935948

25-11-2019

Hi everybody, I've just started using Adobe AEM so please be kind, try explain to me like to your granny... I'm studying a lot but i was given a task to do and i'm going through a micro-heart attack.


OVERVIEW:

I have a site with a news part.
The news part has....many news pages

I have to insert the Google Analytics base snippet just on the news pages that i want and when i want thanks to a dialog hopefully.

For the moment i inserted the snippet on the page template, but now every page sends data...

I also found this link:  Add gtag.js to your site  |  Analytics for Web (gtag.js) which tells you how to not send data by adding a new line.

Anyway the problem still remains, how do i insert that line just on the pages that i don't want to be tracked?

Thanks everybody, i hope i've been clear enough.

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar

MVP

30-11-2019

You can add a checkbox in page property dialog and based on the switch you can add or remove snippet. To take advantage of inheritance you can use inheritedPageProperties

Example -

<sly data-sly-test="${inheritedPageProperties.isEnable}">

// script

</sly>

Answers (0)