Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Stop firing standard GA code on certain pages

ed_mason
Level 2
Level 2

Hi,

By default Satellite fires our GA code to all pages that has the Satellite code on, is there any way to select pages we do not want the pageview to fire on? (so we can use a virtual pageview for instance).

Thanks,

Ed

1 Accepted Solution
AllDayDev
Correct answer by
Employee
Employee

I am not sure about "selecting" pages per se, but you can set conditions. What is the criteria you are using for pages where you don't want to trackPageview?

e.g. are all of the pages under a specific path, or have a certain parameter set, etc.
Or do you just have a list of pages that do not have anything specific to uniquely identify them as different from the other pages?

If you do have some unique criteria, you could add custom JavaScript to test for it to the "Customize Page Code" section of your GA "tool" in DTM (Satellite).

Assuming that you have pages under a specific path that you do not want to track, then here is some example code that assumes your path starts with /nogatracking/ (e.g. http://www.mysite.com/nogatracking/somepage.html):

(!(/^\/nogatracking\//i.test(window.location.pathname)))

This is doing a case-insensitive parsing of the current page's path. If the path starts with "/nogatracking/" then it returns false (which disables the _trackPageview); if not matching this path, then it returns true.

 

There may be other ways of accomplishing what you want, so let us know if this does not meet your needs or if you have any questions.

- Carey

View solution in original post

1 Reply
AllDayDev
Correct answer by
Employee
Employee

I am not sure about "selecting" pages per se, but you can set conditions. What is the criteria you are using for pages where you don't want to trackPageview?

e.g. are all of the pages under a specific path, or have a certain parameter set, etc.
Or do you just have a list of pages that do not have anything specific to uniquely identify them as different from the other pages?

If you do have some unique criteria, you could add custom JavaScript to test for it to the "Customize Page Code" section of your GA "tool" in DTM (Satellite).

Assuming that you have pages under a specific path that you do not want to track, then here is some example code that assumes your path starts with /nogatracking/ (e.g. http://www.mysite.com/nogatracking/somepage.html):

(!(/^\/nogatracking\//i.test(window.location.pathname)))

This is doing a case-insensitive parsing of the current page's path. If the path starts with "/nogatracking/" then it returns false (which disables the _trackPageview); if not matching this path, then it returns true.

 

There may be other ways of accomplishing what you want, so let us know if this does not meet your needs or if you have any questions.

- Carey

View solution in original post