Directing Link Source Traffic (?source=X) to your Website

Overview

Rather than pointing specific traffic sources directly to order page URLs, it is possible to direct the traffic to pages on your own website. This option is useful if you have additional marketing text the visitor should see, or if there are multiple product links on the same page such as a product listing or store front. To setup, you will need to add a small piece of javascript code to your page which contains the order page URLs.

Setup

  • Add the javascript code below to any pages which contain order page URLs pointing to sites.fastspring.com.
  • Add the javascript code below to any pages which you will direct source traffic to, but which do not contain order page URLs.  For example if you will instruct affiliates to point to your homepage, then also add this javascript code to your homepage.
  • Important: the code should be added to the bottom of the page's HTML, immediately before the closing </body> tag.
  • You may then direct source traffic to the modified page such as: http://yourwebsite.com/page.html?source=XYZ
  • The javascript code will scan your page for order page URLs and modify them as needed to pass the source information which was used in the URL to your page.

Javascript Code (add to bottom of page HTML, before closing </body> tag)

<!-- Begin Source Link Script -->
<script type="text/javascript">
<!--
try {
if (window.location.search != null) {
var cookie = ''; var params = ['source','campaign'];
for (var i = 0; i < params.length; i++){
var srcPos = window.location.search.indexOf(params[i]);
if (srcPos != -1) {
var srcStr = window.location.search.substr(srcPos + params[i].length + 1);
var srcAmpPos = srcStr.indexOf('&');
var srcVal = srcAmpPos != -1 ? srcStr.substring(0, srcAmpPos) : srcStr;
var now = new Date(); now.setDate(now.getDate() + 1);
document.cookie = params[i] + '=' + escape(srcVal) + ';' + 'expires=' + now.toGMTString() + '; path=/;';
}
}
}
if (document.cookie != null){
var cookiearray = document.cookie.split(';');
var append = '';
for(var i=0; i<cookiearray.length; i++){
var name = cookiearray[i].split('=')[0]; while (name.charAt(0)==' ') name = name.substring(1,name.length);
var value = unescape(cookiearray[i].split('=')[1]);
if (name == 'source' || name == 'campaign') append = append + (append.length > 0 ? '&' : '') + name + '=' + value;
}
if (append.length > 0){
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++){
var dom = links[i];
if (dom.href.indexOf('sites.fastspring.com') != -1) {
var ch = dom.href.indexOf('?') != -1 ? '&' : '?';
dom.href = dom.href + ch + append;
}
}
var forms = document.getElementsByTagName("form");
for (var i = 0; i < forms.length; i++){
var dom = forms[i];
if (dom.action.indexOf('sites.fastspring.com') != -1) {
var ch = dom.action.indexOf('?') != -1 ? '&' : '?';
dom.action = dom.action + ch + append;
}
} }
}
} catch (e){}
//-->
</script>
<!-- End Source Link Script -->
Have more questions? Submit a request

Comments

Powered by Zendesk