-
Notifications
You must be signed in to change notification settings - Fork 229
Closed
Labels
type:enhancementNew features or improvements to existing features.New features or improvements to existing features.
Milestone
Description
Original issue: snowplow/snowplow#265
Author: https://github.com/joshspivey
There needs to be a way to pass a referrer through a iframe. Lets say you have iframe hosted at A and and host B loads the iframe you cant access the referrer it completely errors out omniture gives you the ability to set this. Now the best way to pass the referrer through is a query string on the iframe this is the less error prone method with less code and most cross browser.
Example:
<iframe src="//:locationA? referrer =http://somesite.com"></iframe>
A solution in the Snowplow JavaScript Tracker is:
window.qs = (function(a) {
if (a == "") return {};
var b = {};
for (var i = 0; i < a.length; ++i)
{
var p=a[i].split('=');
if (p.length != 2) continue;
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
})(window.location.search.substr(1).split('&'));
SnowPlow.getReferrer = function() {
var a = "";
if (window.qs["referrer"]) {
a=window.qs["referrer"];
} else {
try {
a = SnowPlow.windowAlias.top.document.referrer
} catch (c) {
if (SnowPlow.windowAlias.parent) {
try {
a = SnowPlow.windowAlias.parent.document.referrer
} catch (b) {
a = ""
}
}
}
}
Metadata
Metadata
Assignees
Labels
type:enhancementNew features or improvements to existing features.New features or improvements to existing features.