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
Former Community Member

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
Former Community Member

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

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----