Tracking based on query string values

From Market Ruler Help
Jump to: navigation, search

What this article answers

  • You have a page which shows videos and you want to track whether the video was watched or not, and you only have a redirect link available
  • You wish to only track an action when a particular query string appears in the URL
  • You need to extract query string values and pass them to ConversionRuler for tracking

Video Redirect or Query String Check

Regarding the video redirect; say your page is:

http://www.example.com/video.php 

Then you redirect to

http://www.example.com/video.php?watched=1

The following JavaScript will track in lieu of the regular snippet:

<script type="text/javascript"><!-- ConversionRuler snippet here --></script>
<script type="text/javascript">
if (__CR.query("watched")) { __CR.track('XXXX'); } else { __CR.track('0'); }
</script>

Where XXXX is the action code.

Passing Query String Values for tracking

Say the user's email address should be tracked on an unsubscribe page:

http://www.example.com/unsub.asp?email=someone@example.com

To record the email address when this happens:

<script type="text/javascript"><!-- ConversionRuler snippet here --></script><script type="text/javascript">
if (__CR) { __CR.track('XXXX','', __CR.query('email','-No email-'));}
</script>

__CR.query API call to retrieve query string values

If ConversionRuler snippets are loaded, __CR.query is a JavaScript function with the following syntax:

function __CR.query(query_string_name, default_value=null)

It searches the current page for a query string (case-insensitive) and returns the value, or the default_value if not found.