Overwrite single page app setReferrerUrl


#1

We’re confronted with some long urls on our mobile website (single page app) where the basket items are placed in the URL as stringified JSON. This causes some events not making it to the Cloudfront collector. For most of the urls this is fixed by find/replace the document.referrer and push the cleaned url to the tracker with setReferrerUrl/setCustomUrl.

However for our single page app, looking at the referrer field this of course does not give the the real referrer but only the TLD (http://www.domain.com).

Question
Is there a way to read the referrer from the Snowplow Javascript tracker (instead of using document.referrer), clean the referrer and push the clean version to the tracker with with setReferrerUrl?

Currently, single page app events that contain the long url in the referrer (&refr=…) still have a high chance of not making it to the collector.


#2

Hi joost,

The JS Tracker doesn’t expose the referrer field. I have created an issue to add this functionality here. I would suggest the following approach: whenever the URL changes without the page reloading, call setReferrerUrl with the cleaned-up version of the old URL.

Hope that helps,
Fred