Configure Referrer Override JavaScript Code

The code snippet below shows two JavaScript variables, s_referrer and s_pageURL. This code is placed on the ultimate landing page of the redirect.

<script language="JavaScript" src="//INSERT-DOMAIN-AND-PATH-TO-CODE-HERE/AppMeasurement.js"></script>
<script language="JavaScript"><!--
/* You may give each page an identifying name, server, and channel on
the next lines. */
s.pageName=""
s.server=""
s.campaign=""
s.referrer=""
s.pageURL=""
Important: Set s.referrer only once on the page. Setting it more than once with every tracking call or with every link click that is tracked causes double counting of the referrer and related dimensions, such as search engines and keywords.

Redirects using getQueryParam

While the getQueryParam is an easy way to populate Analytics variables with query string values, it must be implemented in connection with a temporary variable so that legitimate referrers are not overwritten when the query string is empty. The best way to use getQueryParam is in connection with the getValue plug in as outlined with the following pseudo-code.

// AppMeasurement 1.x
var tempVar=s.Util.getQueryParam('origref')
if(tempVar)
  s.referrer=tempVar;

// H Code
var tempVar=s.getQueryParam('origref')
if(tempVar)
  s.referrer=tempVar;