Skip to main content
November 25, 2019
Solved

How Insert Google Analytics snipper on different pages

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
Community Advisor
November 30, 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>

Arun Patidar

1 reply

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
November 30, 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>

Translate
Arun Patidar