how to get url segment in javascript? -
i have 1 website like* www_demo_com , advertised on youtube how know users come?
i'was tried using this.
location.host()
but not perfect problem.
it not clear asking here - going assume asking - how know if came website youtube
1) using document.referrer property - documentation can found here - note not work (depends on bunch of things)
you can like:
if (document.referrer && document.referrer != "") { if(document.referrer.indexof("youtube") > -1) { //here know referrer value contains youtube - should execute logic here } }
2) if have given referral link , told them use - need unique string gave them - instance if told them go www.yoursite.com/?ref=some-refferal-link-identifier can this:
if(window.location.href.indexof("some-refferal-link-identifier") > -1) { //here know referrer value contains unique id - should execute logic here }
all being said - best way use google analytics - google built core business on stuff, able use tools track well.
Comments
Post a Comment