Difference between revisions of "Tracking based on query string values"

From Market Ruler Help
Jump to: navigation, search
(Created page with '==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 w…')
 
Line 18: Line 18:
 
  <nowiki><script type="text/javascript"><!-- ConversionRuler snippet here --></script>
 
  <nowiki><script type="text/javascript"><!-- ConversionRuler snippet here --></script>
 
<script type="text/javascript">
 
<script type="text/javascript">
if (CR_QS("watched")) { cr_track('XXXX'); } else { cr_track('0'); }
+
if (__CR.query("watched")) { __CR.track('XXXX'); } else { __CR.track('0'); }
 
</script></nowiki>
 
</script></nowiki>
  
Line 32: Line 32:
  
 
  <nowiki><script type="text/javascript"><!-- ConversionRuler snippet here --></script><script type="text/javascript">
 
  <nowiki><script type="text/javascript"><!-- ConversionRuler snippet here --></script><script type="text/javascript">
if (typeof cr_track != 'undefined') {cr_track('XXXX','',CR_QS('email','-No email-'));}
+
if (__CR) { __CR.track('XXXX','', __CR.query('email','-No email-'));}
 
</script></nowiki>
 
</script></nowiki>
  
 
=CR_QS API call=
 
=CR_QS API call=
  
If ConversionRuler snippets are loaded, '''CR_QS''' is a [[JavaScript]] function with the following syntax:
+
If ConversionRuler snippets are loaded, '''__CR.query''' is a [[JavaScript]] function with the following syntax:
  
  function CR_QS(query_string_name, default_value=null)
+
  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.
 
It searches the current page for a query string (case-insensitive) and returns the value, or the '''default_value''' if not found.

Revision as of 15:27, 26 February 2016

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_QS API call

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.