TROCCO Web Activity Log Collection SDK - Various Functions

Prev Next

summary

The TROCCO Web Activity Log Collection SDK allows you to embed additional JavaScript code or run scripts to

This page explains each method with sample code.

Add event tracking

See Adding Custom Columns below for the following Ja value1'}` section.

Nanalytics('send','event',{category:<category>,action:<action>,label:<label>,value:<value>,sendPageviewIfSessionExpired:(<boolean>)}, {custom_column_1: 'value1'});

The acquired events can be forwarded by selecting Event Log inData Source - TROCCO Web Activity Log.

Various parameters in the code

Parameters marked with ✓ in the required columns must be included in the code.

Parameter Name indispensable data type Description.
action string Types of Interaction
category string Objects used for interaction
label - string Used to categorize events
value - number Figures related to events
sendPageviewIfSessionExpired - boolean If the session has expired when the event fires, whether to renew the session by sending a PageView

code sample

Below is a code sample to log user clicks on external site links.
If you wish to specify the value of a string type parameter, enclose the set value portion in quotation marks.

<a >https://example.com/</a>

Adding Custom Columns

Both page view logs and event logs can include any column in the retrieved data by Custom Columns Setting.

Number of custom columns set

There is a limit to the number of custom columns that can be set.

  • For page view logs: up to 10 columns
  • For event logs: up to 5 columns

code sample

In the following code sample, please edit the column name (the custom_column_x part) and its value accordingly.
Only string type ( string ) values can be specified.

For page view logs

Edit the Nanalytics('send','pageview'); line in the JavaScript code for embedding, as described in Embedding JavaScript Code, as follows

Nanalytics('send','pageview',{custom_column_1: 'value1', custom_column_2: 'value2'});

For event logging

Based on the JavaScript code described in Adding Event Tracking.

<a >https://example.com/</a>

Change existing settings

You can modify some of the internal settings of the TROCCO Web Activity Log Collection SDK by embedding the following additional JavaScript code.

Nanalytics('config','<setting_name>',<setting_value>);

List of settings that can be changed

Default values are usually used for the following settings

Setting name (setting_name) data type Configuration details default value
session_expire_msec number Session timeout in milliseconds 1800000
cookie_prefix string Cookie key name prefix used by TROCCO Web Activity Log Collection SDK __na_
cookie_host string Cookie domain used to store data
If a domain is prefixed with . at the beginning of a domain, sessions and user IDs are shared among the subdomains under that domain.
Site host for delivery
customer_id string Fields for storing site customer IDs, etc.
Please note that the data type is STRING.
-

code sample

The Nanalytics('setup',...) and Nanalytics(' send ',...) lines of the embedding code, as described in Embedding JavaScript Code. line and Nanalytics('send',...) Add the following line between the Nanalytics('setup',...) and Nanalytics('send',...) lines of the embed code.
If you want to change the setting value of a string type, enclose the setting value portion in quotation marks.


Acquisition of collected data by script execution

Data collected by the TROCCO Web Activity Log Collection SDK can also be retrieved by executing the following script
Please use it when you want to check the value with the developer tools of your web browser, etc.

Nanalytics('get',[<callback_function>]);

List of data that can be retrieved by the script

The argument of the callback function will be an object with the following property name
If the value does not exist, it is undefined.

Property Name data type Description.
site_id string Site-specific ID issued by primeNumber
user_id string 1st party cookie (site domain) based unique ID (generated by UUIDv4)
session_id string Unique ID within a session (generated by UUIDv4)
browser_height number Browser Height
browser_width number Browser Width
language string Browser Language
session_num number Total number of sessions for the user in question
session_start_time number Session start date and time
session_channel_url string URL of the incoming flow path at the beginning of the session
medium string Value equivalent to utm_medium in Google Analytics
source string Value equivalent to utm_source in Google Analytics
campaign string Value equivalent to utm_campaign in Google Analytics
keyword string Value equivalent to utm_term in Google Analytics
ad_id string Ad IDs such as Google Ads
url string Normalized and decoded URL
referer_url string Normalized and decoded referrer URL
customer_id string Customer ID
browser_time number Date and time the PageView occurred in the user's browser time
pv_num number Cumulative number of PageViews in the relevant session

code sample

The following is a code sample that outputs the value of session_num.

Nanalytics('get',function(value) { console.log(value.session_num) });