Expand my Community achievements bar.

SOLVED

How Insert Google Analytics snipper on different pages

Avatar

Level 1

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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>



Arun Patidar

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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>



Arun Patidar