Implementation without GTM

This manual describes how to implement Roivenue Measurement in your web that does not use Google Tag Manager.

The following tracking script sets cookies into the users device. It tracks data which may be used for marketing optimization, content optimization or user segmentation. In some legislations the user needs to make an explicit consent before this code can be legally executed on his or her device.

As we only act as a data processor, you are responsible for obtaining consent in accordance with applicable legislation. If our tracking script gets activated and you have not complied with the applicable rules in obtaining user consent, you may be at risk of sanctions for which we are not responsible

Prerequisites

  • Property ID - You will need this to set up your script correctly. Contact your account manager to obtain it.

Visits tracking on all pages

  1. Insert this entire code on every page inside <head> </head> element.

<!-- BEGIN Roivenue Measurement -->
<script>
  var rm_config = {
    property_id : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    api_url: "https://tr.roivenue.com", 
    autocapture: true
  };
</script>  
<script src="https://tr.roivenue.com/static/init_v2.js"></script>
<!-- END Roivenue Measurement -->
  1. Adjust the property_id - insert the ID you have from your account manager.

Start Tracking Events

  1. To start tracking events, call the startMeasurement function of the global $rm object:

$rm.startMeasurement();

Tracking events will start only after you call the startMeasurement function. This allows you to evaluate user consent with cookies first and start tracking events only after that.

When script above is included, and $rm.startMeasurement(); is called, it automatically tracks page views and page leave events. The script will automatically track traffic source information from HTTP referrer and UTM parameters, device type and other useful information.

After tracking script is initialized (by code snippet above), custom events can be then tracked by calling capture() function of $rm global object (see Conversion Tracking section for an example).

The startMeasurement function has an optional parameter which is a configuration object.

$rm.startMeasurement({ /* options */ });

Persistence

$rm.startMeasurement({ persistence: 'localStorage+cookie' });

The persistence option allows you to specify how user data is stored in the browser. The persistence option can have one of the two values:

  • persistence: "localStorage+cookie" (default): Cookies are used in this case

  • persistence: "sessionStorage": Stores everything in sessionStorage, cookies are not used.

  1. If you have a full consent from your website visitor, we recommend using the default settings of persistence.

  2. When there is a limited consent with tracking, you should set up persistence to sessionStorage

$rm.startMeasurement({ persistence: 'sessionStorage' });
  1. To completely exclude user from tracking, the startMeasurement function should not be called at all.

When a user changes his consent with cookies at any point, this change can be passed to Roivenue Measurement using setConfig function. This function has a single parameter which is a configuration object with the same structure as in startMeasurement function.

$rm.setConfig({ /* options */ });

setConfig function can be called only after startMeasurement function has been called.

An example of calling setConfig to set the persistence to a cookie:

$rm.setConfig({ persistence: 'localStorage+cookie' });

As we only act as a data processor, you are responsible for setting up the Roivenue Measurement in line with applicable legislation in your country.

Conversions Tracking

Next, we need to capture all conversions created by your customers.

  1. To do that, call capture conversion to track an e-commerce purchase event:

$rm.capture('conversion', {
  conversionType: 'purchase', //there may be a different type like 'userRegistration' etc.
  conversionId: 'XXX12346', //unique conversion ID 
  conversionValue: 123.5, //decimal number - monetary value of the conversion (optional)
  currencyCode: 'XXX' //Three letter ISO-4217 code of currency, (required if conversionValue is specified)
});

Multiple Conversions Setup

To track other conversion type events, you can easily track a ‘conversion’ event exactly the same as described above and just change the conversionType.

User Identification

This step is optional

We can use User ID to track users across devices. This ID is typically available only for users which logged in on your website.

  1. Whenever the user logs in or makes a purchase that you are able to connect with a unique user identifier, call this:

$rm.identify('[user unique id]')

The User ID should not be a personal sensitive information. For privacy protection reasons it is recommended to use an artificial identifier or a hash.

Additional Changes for Single Page Applications

Most e-commerce solutions use standard navigation between pages and you can skip this section. But if your website is a javascript single page application, then there need to be some changes.

  1. Set the rm_config.autocapture to falseon all pages.

  2. To track pageviews, call capture function after every navigation (when page location changes):

$rm.capture('pageview', {});

Tracking Other Events

Roivenue Measurement supports tracking of other on-site events as well. If you are interested in custom implementation, let us know.

Last updated