Tracking Order Amounts: Advanced

From Market Ruler Help
Jump to: navigation, search

How to set up ConversionRuler Commerce Tracking snippets.

To pass financial information to our servers you will need to modify the “order snippet”. This will generally require some coding in the technology that your shopping cart uses.

The Tracking Snippet page allows you edit your snippet to add values you have configured.

Technical Documentation

The tracking snippet needs to be modified with the values for the orders that you might track. Two JavaScript variables are recognized by ConversionRuler.

The basic change you need to make is filling in the ORDER_AMOUNT and ORDER_NUMBER values:

var cramount = 'ORDER_AMOUNT',
crtext = 'ORDER_NUMBER';
__CR.track('3');

Because "cramount" and "crtext" are Javascript values, they can be defined anywhere on the page prior to invoking our snippet.

It is best to quote them with single quotes to avoid JavaScript errors.

Microsoft Active Server Pages Example

For example, if you are using Microsoft Active Server Pages, your snippet may look like this:

var cramount = '<%= oRS("subtotal") %>',
crtext = '<%= oRS("order_id") %>';
__CR.track('3');

PHP Example

If you are using PHP in your server, you snippet may appear like this:

var cramount = '<?= $order['subtotal'] ?>',
crtext = '<?= $order['id'] ?>';
__CR.track('3');

When your pages generate, the final page should look like this for an order of $199.99 with order number 2369:

var cramount = '199.99',
crtext = '2369';
__CR.track('3');

JavaScript-only Example

Some shopping carts actually generate JavaScript variables with the order amount and order number in them already on the page, in which case no quoting is required:

var cramount = CAOrderSubTotal,
crtext = CAOrderID;
__CR.track('3');

All variables are optional, so to just include the order amount:

var cramount = '199.99';
__CR.track('3');

Comprehensive Example

And, as a final example, you can pass up to four different amounts and strings with each action:

var cramount0 = "USD $33.55";
var cramount1 = "$5.34";
var cramount2 = "$2.33";
var cramount3 = "$512.23";
var crtext0 = "ORD1850-6923942639234";
var crtext1 = "john-doe@example.com";
var crtext2 = "2009-05-30 44:33:22";
var crtext3 = "affiliate5434";
__CR.track('3');

Special characters

Order amounts may include special characters such as $ or € - our servers will strip away all of the non-numerical information.

Using different variables which mean the same thing

Note that the JavaScript variables "cramount" and "cramount0" are analogous, as are "crtext" and "crtext0".

If, for some reason, you define cramount and cramount0 on your page, then cramount will be recorded, and cramount0 is not recorded.

var cramount = "USD $33.55";
var cramount0 = "USD $330000324.55";
__CR.track('3'); // Records $33.55 only

For more help

We have installed order tracking in hundreds of shopping carts so if you are stuck, feel free to contact us!

Related