- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
How can I get a page number cookie on a subdomain (that starts on first visit to subdomain) while keeping the session page view count in the the utag_main__pn?
Solved! Go to Solution.
Hi @annah_brown
So not the easiest thing to accomplish. However saying that, you could do something like:
(function(sub_domain, cookie_name, a,b,c,d, e){ if (location.host === sub_domain) { a = (new Date()).getTime(); b = utag.loader.RC(cookie_name); c = a + parseInt(utag.cfg.session_timeout); d = a; if (!b) { b = {}; } else if (b.ses_id && typeof b._st != "undefined" && parseInt(b._st) < a) { delete b.utag_main.ses_id; } if (!b.ses_id) { b.ses_id = d + ''; b._ss = b._pn = 1; b._sn = 1 + parseInt(b._sn || 0); } else { d = b.ses_id; b._ss = 0; b._pn = 1 + parseInt(b._pn); b._sn = parseInt(b._sn); } if (isNaN(b._sn) || b._sn < 1) { b._sn = b._pn = 1; } b._st = c + ''; e = utag.cfg.domain; utag.cfg.domain = location.host; utag.loader.SC(cookie_name, { "_sn": b._sn, "_ss": b._ss, "_pn": b._pn + ";exp-session", "_st": c, "ses_id": d + ";exp-session" }); utag.cfg.domain = e; } }("sub.domain.com", "utag_sub_domain"));
This can be placed into a JS extension, scoped to DOM Ready. Or "All Tags" with "Before Load Rules" selected. If the later you will need to wrap the above code in a block like:
if (!utag.sub_domain_count) { //Insert other block of code here utag.sub_domain_count = true; }
This will now give you an additional cookie on the sub domain, that contains counters just for that domain, as well as having the main cookie, with the overall counter.
Hopefully this helps.
Regards,
Adrian
Copyright All Rights Reserved © 2008-2023