Javascript SDK

Renta Javascript SDK — allows you to collect events, sessions and user-level data from the website. SDK provides data streaming to the following destinations: 

  • Snowflake
  • Google BigQuery
  • Clickhouse
  • Facebook Conversions API
  • Webhooks

The advantage of this data source is the ability to support server-side integration, which provides data collection on behalf of the first-party data.

The whole process of setting up data collection can be divided into several simple steps:

  1. Data source creation;
  2. Custom domain creation;
    Required only for server-side implementation; 
  3. Event tracking.  

Data source creation

Select Javascript in the integration Catalog to create a new data source.

 

Then specify the following settings:

Site URL

Specify the URL of the site for which you want to set up tracking.

Server-side implementation

Allows you to configure server-side tracking. By default, tracking is done by Renta, but we strongly recommend to use a subdomain of your website.

In order o do this, enable server-side implementation and specify the following settings:

Custom domain

Enter the subdomain of your website on behalf of which the tracking will take place in the Custom domain field. For instance, collect.yourdomain.com

IP address

CopyIP address of the dedicated server for your project and specify it as the A-record for the specified subdomain. If you do not perform the configuration by yourself, then use the instructions for the IT department.

Installing Code

Copy the received code into the Installing Code field install it on all pages of the site. For instance, using Google Tag Manager.

Now you can go to the event settings on the site side.

Configuring Event Tracking

Using the Javascript SDK, you can configure 4 types of events:

Event type Description
page Captures information about page views.
track Provides tasks for tracking user actions. For instance to track transactions or subscribe to a newsletter.
identity  Recommended to use only to collect users’ personal data. Helps to build a user profile.
group The event is used to track a group of users.

Page

This is the basic event that sends information about the page view. Recommended to call this event on all pages of the site.

To call a page view event, use the code below:

<script> 
 analytics.page()
</script> 

You can also specify additional attributes if the standard data is not enough. To modify a page type event properly, read this guide.

Track

Use it to record any user actions on the site. You can create custom event names with any number of descriptive attributes.

You can see the scenarios for using this type of event below:

  • Registration in the product;
  • Subscribe to the newsletter;
  • Making a transaction in the online store;

Thus, you can create any events that are valuable for your project.

Example of calling javascript code to commit a transaction:

<script>
  analytics.track('Transaction completed', {
  transactionId: "ABC00001",
  transactionRevenue: 1000
});
</script>

Each track event consists of:

Field name Mandatory Field description
Event name The name of the event. For instance, Transaction completed.
Properties

This is any additional information that you can send along with the event.

You can specify any number of additional attributes.

As an example, the transactionId and transactionRevenue variables are transfered to the Transaction completed event. They describe the amount and number of order. These variables are additional attributes of the event. You can delete them, rename them, or specify your own attributes. 

Identity

It is necessary to use Identity only at the moment of user identification. Below are the scenarios when one should call this event type:

  • After successful registration;
  • After successful authorization;
  • When the user updated their contact information;

To call the event, use javascript code:

<script>
 analytics.identify("userid_variable", {
  name: "Elon Musk",
  email: "elon@tesla.com",
  company: "Tesla Motors"
 });
</script>

In addition to the standard fields, identity supports the following fields:

Fields name Mandatory Field description
userId Unique user ID in your database.
Properties

This is any additional information that you can send along with the event.

 

You can specify any number of additional attributes.

 

As an example, the javascript code contains the variables name, email, company. These variables are additional attributes of the event. You can delete them, rename them, or specify your own attributes. 

Group

The event is used to unite users into a common group.

The name of the company, department, or project can be used as a group. Thus, you can use any internal identifier in your system.

To call the event, use javascript code:

<script>
 analytics.group("groupid_variable", {
  company: "Tesla",
  industry: "Auto Manufacturing",
  employees: 70757
 });
</script>

In addition to the standard fields, group supports the following fields:

Field name Mandatory Field description
groupId Unique ID of the group in your database.
Properties

This is any additional information that you can send along with the event.

 

You can specify any number of additional attributes.

 

As an example, the javascript code contains variables company, industry, employees. These variables are additional attributes of the event. You can delete them, rename them, or specify your own attributes. 

Structure of standard fields

Initially, events of all types come with a standard list of fields that are available for transmission in server-side integrations and are also stored in a separate table during DWH integration.

The list of standard fields, as well as their description, is available in the table below:

Field name Type of data Description
dateTime datetime Date and time of the event in UTC
date date Date of the event in UTC
sendAt datetime Date and time when the event was sent from the client side
eventId String Unique Event ID
eventType String Event type
eventName String Event name
properties String Json object that contains custom event attributes
anonymousId String Unique cookie values
userId String UserId number. Contains the value passed to Google Analytics.
groupId String Unique group value (only available for a group type event)
content String Maintance of utm_content
medium String Maintance ofutm_medium
source String Maintance of utm_source
term String Maintance of utm_term
campaign String Maintance of utm_campaign
dataSource String The data source for the request. Initialy, requests from analytics.js they will have the web value, and requests from the mobile SDK will have the app value.
device String Device type: desktop, tablet, mobile, TV. 
deviceBrowser String Browser (for instance, Chrome or Firefox).
deviceBrowserVersion String Browser version.
deviceOperatingSystem String Operating system(for instance, Macintosh or Windows).
deviceOperatingSystemVersion String Operating system version.
deviceIp String IP-adress
country String Country
city String City
region String Region
deviceUserAgent String User Agent
deviceScreenHeight Int Resolution of the user’s screen in pixels by height
deviceScreenWidth Int Resolution of the user’s screen in pixels by width
deviceViewPortHeight Int The size of the viewing area in the browser by height
deviceViewPortWidth Int The size of the viewing area in the browser by width
deviceDocEncoding String Encoding. For instance, UTF-8.
location String URL with additional parameters. For instance: https://site.com/catalog/platya?page=2
hostname String

Domain. 

For instance: https://site.com/

path String

Path of the pages URL. 

For instance: /catalog/platya

title String Title of the page.
page String

The full URL path.

For instance: https://site.com/catalog/platya

documentReferrer String If the medium field has the referral value, the path of the traffic source is indicated here, and the host name is contained in the source field.
fbclid String The Facebook Ads click ID that is passed to the URL when the ad is clicked.
gclid String The Google Ads click ID that is passed to the URL when the ad is clicked.
ydclid String The Yandex Direct click ID that is passed to the URL when the ad is clicked.
ga_cookie_id String The unique meaning of Google Analytics cookies
ym_cookie_id String The unique meaning of Yandex Metrika cookies
fbc_cookie_id String The unique meaning of Facebook cookies
fbp_cookie_id String The unique meaning of Facebook cookies
offset String A service parameter of the Javascript SDK. Used to count sessions (the session table is only available in integration with DWH).