Is it possible to have Analytics fire only on certain pages? I tried adding a path condition in DTM to the page load rule, but that didn't seem to make any difference at all. I'm now trying to accomplish the same result by deactivating the beacon via the following custom code:
if(document.location.href.indexOf("whatever")!=-1){
return false
}
Does anyone have any tips on what the actual best way to have Analytics only fire on certain pages?
Solved! Go to Solution.
Views
Replies
Total Likes
I think the solution might be to go to Analytics tool in DTM and in the customized code section. only put return false. I think this make the Analytics initialise but not send an image request.
Next create page load rules and set conditions page on url or path or whatever and send the analytics calls.
Go to Global Variables section in DTM, and open the custom script section. Add the code s.abort(). This will disable any default/global tracking. Once you do this, you should be able to create seperate rules for each pages based on your path conditions.
Views
Replies
Total Likes
I think the solution might be to go to Analytics tool in DTM and in the customized code section. only put return false. I think this make the Analytics initialise but not send an image request.
Next create page load rules and set conditions page on url or path or whatever and send the analytics calls.
Thanks Alexis-- customer care confirms this as the correct solution, although I'm still not seeing the results that I would expect. I'll follow up with any additional insight once I have a complete solution. I would imagine that the issue lies with me and how I'm setting up the rules/conditions, rather than this approach itself.
Views
Replies
Total Likes
Actually, the advice has changed, so my initial method would appear to be correct, although I'm still not seeing the expected results in my reporting.
In my original post I was using the following logic:
if(document.location.href.indexOf("whatever")!=-1){
return false
}
As I'm trying to fire Analytics only where "whatever" is present in the URL, this was slightly incorrect, as the comparison operator should have been == and not !=.
The guidance from customer care is:
You can navigate to Analytics tool (link) in the web property and "Open Editor" from Customize Page Code section (screenshot attached). Therein, you can write a code with the below logic. Please note, I won't be able to share the exact code, however I'll be just sharing the logic that can be converted to the code.
if ("Path" does not contain "servletcontroller")
{
return false;
}
Really scratching my head at this point...
Hi - davidp86482746
Yes, you can navigate to tools ->Adobe Analytics - > Custom Code and set following condition -
if (window.location.pathname.indexOf("path1") != -1 || window.location.pathname.indexOf("path2") != -1)
{
//set custom pageCode here
}
else
{
return false;
}
This way the page view image request will only be processed for paths added in your condition above.
Views
Likes
Replies