Difference between revisions of "Tracking based on query string values"
From Market Ruler Help
(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…') |
|||
(One intermediate revision by the same user not shown) | |||
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 ( | + | 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 ( | + | if (__CR) { __CR.track('XXXX','', __CR.query('email','-No email-'));} |
</script></nowiki> | </script></nowiki> | ||
− | = | + | =__CR.query API call to retrieve query string values= |
− | If ConversionRuler snippets are loaded, ''' | + | If ConversionRuler snippets are loaded, '''__CR.query''' is a [[JavaScript]] function with the following syntax: |
− | function | + | 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. |
Latest revision as of 15:27, 26 February 2016
Contents
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.