alex35mil / sourcebuster-js

Track the sources of your traffic
https://alexfedoseev.github.io/sbjs
MIT License
413 stars 93 forks source link

How can I test sourcebuster? #12

Closed jamesmehorter closed 7 years ago

jamesmehorter commented 7 years ago

Hi,

Sourcebuster looks great! Though I'm having an issue testing it..

In my page I call sbjs.init() and then something like console.log(sbjs.get.current.src);. When I visit my page directly I properly get (direct). And if I visit my site via site.com?utm_source=blah, I properly get blah.

However, how can I test that 'google' or 'facebook', or others get returned properly (before I deploy to production)?

I tried having google redirect me to my local/dev site, e.g. by visiting https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&url=http%3A%2F%2Fblah.com and clicking 'The previous page is sending you to http://blah.com.' But console.log(sbjs.get.current.src); still outputs (direct).

For Facebook, I messaged myself the url to my local/dev site and then clicked that link, though console.log(sbjs.get.current.src); still outputs (direct).

I also used Referer Control to spoof the referrer header, and can verify that the GET header correctly contains Referer:http://google.com, console.log(sbjs.get.current.src); still outputs (direct).

I also attempted to clear cookies before each of those tests.

Any help, insight you could provide would be excellent! Thank you!

alex35mil commented 7 years ago

Hi, thanks!

Most likely this is the issue with https -> http navigation. Can you check the value of document.referrer in the browser console?

Answering the title question, I implemented sourcebuster in ruby at the first place and at those times I used this to test it.

jamesmehorter commented 7 years ago

Thanks so much! You're absolutely correct! I adjusted my local dev to serve via https, and then used the Google redirect (https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjCtv3TosfSAhUs6YMKHbS8CfAQFggaMAA&url=https%3A%2F%2Fmy.local.site&usg=AFQjCNH6cQf-rEVsmH54WujQjUyMobzjaw&bvm=bv.148747831,d.amc) I see the referrer as 'google'.

I'll have a read through the ruby testing solution you linked to. Closing this issue out. Thanks!! :)