Expand my Community achievements bar.

SOLVED

Stop firing standard GA code on certain pages

Avatar

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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