I try to set a custom segment (not based on roles or profile data) on a single node with add_js, but drupal insert the set_var script over the google analytics script. And my custom segment isn't tracked.
Is it possible to change the weight or do something like custom snippets, but not for all the site, just 1 page?
Comments
Comment #1
hass commentedComment #2
hass commentedI think this is currently not possible and may never be as this would collide with profile tracking (set_var can only used once). You might get an idea how this may be possible if you read http://drupal.org/node/393070#comment-1326766, but your need to solve this yourself or by writing a custom module (like http://drupal.org/node/231451#comment-905484) - only for this one task.
This request may be seen as a duplicate of #231451: Add hook to alter data before sending it to browser.
Comment #3
Anonymous (not verified) commentedI will try this:
Disable tracking code on this node (by url) and add the full tracking code with add_js.
What do you think?
Comment #4
hass commentedNot really. You cannot add the set_var via add_js... it will ever stay in a wrong position. The set_var line needs to come between
var pageTracker = _gat._getTracker("UA-12345-1");andpageTracker._trackPageview();. This is the main problem you can only solve today by creating a custom module or theme function that alters the footer code in the way you can see at http://drupal.org/node/231451#comment-905484.Comment #5
hass commentedI have another idea... something that is ready :-).
Install the sections.module (latest DEV) and assign section to your node. Afterwards you can have a custom sections-page-[section-ID].tpl.php what will become a 1:1 copy of your current page.tpl.php. Than you exclude this node from tracking and add the tracking code by hand to sections-page-[section-ID].tpl.php.
Comment #6
Anonymous (not verified) commentedThank you for your suggestion, but I meant add the full tracking code, not just the setVar via add_js this way:
Comment #7
Anonymous (not verified) commented-