Dynamic Google Analytics Account in GTM -
i new gtm , in learning phase. wanted implement gtm on 1 of websites , requirement
based on url, analytics shall sent different ga accounts.
below example
url gaaccount ------------------------------------ http://domain.com/abc ua-xxxxxabc http://domains.com/def ua-xxxxxdef http://domain.com/xyx ua-xxxxxxyz http://domains.com/qwe ua-xxxxxqwe
i tried make lookuptable in gtm same mentioned above , operate on basis of url problem here actual url contains long encrypted string below
http://domain.com/abc/!ut/b/dasdasd654654weewexx879987xxxsswwo_adasdw_wewqewqe
so lookuptable can not match url , error in gtm console undefined account
i know page url variables provided gtm not sure how combine page hostname
, page path
1 variable , strip unwanted string page path
, match exact url.
lookup table did not work becuase matches entire url given input check http://domain.com/abc equals http://domain.com/abc/!ut/b/dasdasd654654weewexx879987xxxsswwo_adasdw_wewqewqe false
what can here create custom javascript variable returns tracking id if condition matches here example
function(){ if("{{page url}}".match("domain.com/abc")!==null){ return("ua-xxxxxabc") } else if("{{page url}}".match("domain.com/def")!==null){ return("ua-xxxxxdef") } else if("{{page url}}".match("domain.com/xyx")!==null){ return("ua-xxxxxxyz") } else if("{{page url}}".match("domain.com/qwe")!==null){ return("ua-xxxxxqwe") } }
hope helps
cheers analyticsml
Comments
Post a Comment