Stop firing standard GA code on certain pages

ed_mason

15-10-2015

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

Accepted Solutions (1)

Accepted Solutions (1)

AllDayDev

Employee

15-10-2015

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

Answers (0)