Skip to main content

Javascript

Before I start

Piano Analytics SDKs have been designed for the Piano Analytics solution. Data sent through these SDKs will not be processed within the Analytics Suite 2.

attention

If your Analytics perimeters are certified (ACPM / Mediamétrie), you still need to use the SmartTag SDKs (at least for your pages).

"xtor" marketing campaigns syntax will not be recognized anymore. Please use "at_" instead.

Load the library

The first step to use our SDK is to load the JS file. You have two ways to do this:

CDN

You can load the library from https://tag.aticdn.net/piano-analytics.js:

<script type="text/javascript" src="https://tag.aticdn.net/piano-analytics.js"></script>

Download

You can also download the file from Github and upload it on your own server.

Configuration

In order to setup your tracking, you need to set the configuration of the library.

To do this, we offer two configuration methods depending on what you want to setup.

Basic configuration

pa.setConfiguration(configurationKey, configurationValue);

// or

pa.setConfigurations(configurationObject)
tip

We recommend setting the configuration within the <head> of your page.

Here is the minimal configuration required:

pa.setConfiguration("site", 123456789); // your site id
pa.setConfiguration("collectDomain", "https://logsx.xiti.com"); // your collection domain

// or

pa.setConfigurations({
site: 123456789,
collectDomain: "https://logsx.xiti.com"
});
note

Don't hesitate to read our collection methods article to find the collection domain that has been assigned to you.

You can also use a custom domain thanks to our CDDC.

Here are the available configurations:

CategoryNameDescriptionTypeValueMore info
GlobalcollectDomainCollection domainstringhttps://logsx.xiti.comView
GlobalsiteSite idint123456789View
GlobalpathRequest pathstringevent
GlobaladdEventURLAutomatically adds a page_url property to all events, containing the URL of the current pagestringfalse, withoutQS (default), true
PrivacysendEventWhenOptoutDo you want to send events when optout?booleantrue (default), false
CampaigncampaignPrefixChoose with an order of priority the type of campaign to be collectedarray['at_']View
CampaignenableUTMTrackingUTM parameters collected as propertiesbooleantrue (default), falseView

SDK configuration

This method is ran asynchronously and override SDK configuration.

You have to define it before SDK's loading.

window._pac = window._pac || {};

<script type="text/javascript" src="https://tag.aticdn.net/piano-analytics.js"></script>
tip

We recommend setting the configuration within the <head> of your page.

Here an example of what you can configure:

window._pac = window._pac || {};
_pac.cookieDomain = '.mysite.com';
_pac.privacyDefaultMode = 'no-consent';

<script type="text/javascript" src="https://tag.aticdn.net/piano-analytics.js"></script>

Here are the available configurations:

CategoryNameDescriptionTypeValueMore info
GlobalcookieDomainDomain of cookie depositstringmysite.com (current domain by default)
GlobalcookieSameSite"SameSite" flag in cookies in client-sidestringlax (default), none, strict
GlobalcookieSecure"Secure" flag in cookies in client-side cookiesbooleantrue (default), false
GlobalencodeStorageBase64Storage value encode (base64)booleantrue, false (default)
PrivacyprivacyDefaultModePrivacy mode by defaultstringoptin (default)View
StoragestorageLifetimePrivacyLifetime Storage Privacy valueint395 (days)View
StoragestorageLifetimeUserLifetime Storage User valueint395 (days)View
StoragestorageLifetimeVisitorLifetime Storage Visitor valueint395 (days)View
StoragevisitorStorageModeRelative or fixed cookie lifetime value for visitorstringfixed (default), relative
Visitor PolicyisVisitorClientSideIs cookie deposit client side ? If false, server sidebooleantrue (default), false
note

All configurations in "Basic configuration" are compatible with "SDK configuration" method.

Specification

Piano Analytics Javascript SDKs are based on the sendBeacon browser API. Please refer to the documentation if you want more information.

Changelog

You can find the Javascript changelog directly on GitHub.