Skip to main content
Skip table of contents

JavaScript Tracking Client In Depth Documentation

User guide

You can use the JavaScript tracking client to track any application that supports JavaScript, for example websites!

This guide will explain how you can use the JavaScript tracking client to customize the way some of the web analytics data is recorded in Atrilyx.

Finding the Atrilyx Tracking Code

To use all the features described in this page, you need to use the latest version of the tracking code. To find the tracking code for your website, follow the steps below:

  • log in to Atrilyx with your admin or Super User account

  • click on the "administration" (cog icon) in the top right menu

  • click on "Tracking Code" in the left menu (under the "Measurables" or "Websites" menu)

  • click on "JavaScript Tracking" section

  • select the website you want to track

  • copy and paste the JavaScript tracking code into your pages, just after the opening <body> tag (or within the <head> section)

The tracking code looks as follows:

<!-- Atrilyx -->

<script type="text/javascript">

  var _paq = window._paq = window._paq || [];

  _paq.push(['trackPageView']);

  _paq.push(['enableLinkTracking']);

  (function() {

    var u="//{$ATRILYX_URL}/";

    _paq.push(['setTrackerUrl', u+'Atrilyx.php']);

    _paq.push(['setSiteId', {$IDSITE}]);

    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];

    g.type='text/javascript'; g.async=true; g.src=u+'Atrilyx.js'; s.parentNode.insertBefore(g,s);

  })();

</script>

<!-- End Atrilyx Code -->

In your tracking code, {$ATRILYX_URL} would be replaced by your Atrilyx URL and {$IDSITE} would be replaced by the idsite of the website you are tracking in Atrilyx.

This code might look a bit strange to those of you familiar with JavaScript, but that is because it is made to run asynchronously. In other words, browsers will not wait for the Atrilyx.js file to be downloaded in order to show your page.

For asynchronous tracking, configuration and tracking calls are pushed onto the global _paq array for execution, independent of the asynchronous loading of Atrilyx.js. The format is:

_paq.push([ 'API_method_name', parameter_list ]);

You can also push functions to be executed. For example:

var visitor_id;

_paq.push([ function() { visitor_id = this.getVisitorId(); }]);

or for example, to fetch a custom variable (name, value) using the asynchronous code:

_paq.push(['setCustomVariable','1','VisitorType','Member']);

_paq.push([ function() { var customVariable = this.getCustomVariable(1); }]);

You can push to the _paq array even after the Atrilyx.js file has been loaded and run.

If your Atrilyx tracking code doesn't look like this one, you may be using the deprecated version. Older versions still work as expected and will track your visitors, but we highly recommend that you update your pages to use the most recent tracking code.

Requirements

Supported browsers

The JavaScript tracker runs on all browsers that support the JSON API. This includes IE8 and higher. Click here to see a full list of supported browsers. If you need to support IE7 and older then you could load a polyfill that makes window.JSON available such as JSON3. This polyfill would need to be loaded before the Atrilyx JS tracker is loaded.

 

JavaScript tracker features

Custom page title

By default Atrilyx uses the title of the HTML page to track the page title, you can customize it by using the function setDocumentTitle:

_paq.push(['setDocumentTitle', document.title]);

_paq.push(['trackPageView']);

If you track multiple sub-domains in the same website, you may want your page titles to be prefixed by the sub-domain to make it easy for you to see the traffic and data for each sub-domain. You can do so simply:

_paq.push(['setDocumentTitle', document.domain + "/" + document.title]);

_paq.push(['trackPageView']);

Advanced users can also dynamically generate the page name, for example, using PHP:

_paq.push(['setDocumentTitle', "<?php echo $myPageTitle ?>"]);

_paq.push(['trackPageView']);

Custom page URL

By default, Atrilyx uses the URL of the current page as the Page URL in reports. You can customize the page URL to track by using the function setCustomUrl

Manually trigger events

By default, Atrilyx tracks page views when the JavaScript tracking code loads and executes on each page view.

However, on modern web applications, user interactions do not necessarily involve loading a new page. For example, when users click on a JavaScript link, or when they click on a tab (which triggers a JS event), or when they interact with elements of the user interface, you can still track these interactions with Atrilyx.

To track any user interaction or click with Atrilyx, you can manually call the JavaScript function trackEvent(). For example, if you wanted to track a click on a JavaScript menu, you could write:

<a href="#" onclick="_paq.push(['trackEvent', 'Menu', 'Freedom']);">Freedom page</a>

 

Manually trigger goal conversions

By default, Goals in Atrilyx are defined as "matching" parts of the URL (starts with, contains, or regular expression matching). You can also track goals for given page views, downloads, or outlink clicks.

In some situations, you may want to register conversions on other types of actions, for example:

  • when a user submits a form

  • when a user has stayed more than a given amount of time on the page

  • when a user does some interaction in your Flash application

  • when a user has submitted his cart and has done the payment: you can give the Atrilyx tracking code to the payment website which will then register the conversions in your Atrilyx database, with the conversion's custom revenue

To trigger a goal conversion:

// logs a conversion for goal 1

_paq.push(['trackGoal', 1]);

You can also register a conversion for this goal with a custom revenue. For example, you can generate the call to trackGoal() dynamically to set the revenue of the transaction:

// logs a conversion for goal 1 with the custom revenue set

_paq.push(['trackGoal', 1, <?php echo $cart->getCartValue(); ?>]);

 

Accurately measure the time spent on each page

By default, when a user visits only one page view during a visit, Atrilyx will assume that the visitor has spent 0 second on the website. This has a few consequences:

  • when the visitor views only one page view, the "Visit duration" will be 0 second.

  • when the visitor views more than one page, then the last page view of the visit will have a "Time spent on page" of 0 second.

It is possible to configure Atrilyx so that it accurately measures the time spent in the visit. To better measure time spent in the visit, add to your JavaScript code the following:

// accurately measure the time spent in the visit

_paq.push(['enableHeartBeatTimer']);

Atrilyx will then send requests to count the actual time spent in the visit, as long as the user is actively viewing the page (i.e. when the tab is active and in focus). The heart beat request is executed when:

  • switching to another browser tab after the current tab was active for at least 15 seconds (can be configured see below).

  • navigating to another page within the same tab.

  • closing the tab.

// Change how long a tab needs to be active to be counted as viewed in seconds/

// Requires a page to be actively viewed for 30 seconds for any heart beat request to be sent.

_paq.push(['enableHeartBeatTimer', 30]);

Note: When testing the heart beat timer, remember to make sure the browser tab has focus and not eg. the developer tools or another panel.

Ecommerce tracking

Atrilyx allows for advanced and powerful Ecommerce tracking.

Within the reports, you can benefit from the following metrics:

·         Ecommerce Orders – Keep track of the total number of website sales in aggregate, or over specific periods.

·         Products Purchased – You can track the number of products that have been purchased within your total orders. It is also possible to break this down further with the Products report to get detailed statistics.

·         Total Revenue – The amount of revenue generated from your sales (including tax, shipping, and subtracted discounts). See how much you’ve made within specific periods at a glance.

·         Subtotals – The order subtotal, excluding shipping and tax. This can help you get a better understanding of your sales revenue without having to account for varying regional and international charges.

·         Tax – The total amount of tax charged on all sales. Tracking or excluding this value can help you to understand your pre-tax and post-tax profits across your website.

·         Shipping – The total shipping costs charged on all sales. When plotted against revenue, you can work out the effectiveness of free shipping offers.

·         Discounts – The total discount applied to all sales. This helps to quantify the effective marketing costs of discount campaigns.

·         Average Order Value (AOV) – This is calculated from the total revenue divided by the total number of orders. It can be a useful metric to help you design and track the efficiency of campaigns to increase the value of your orders and ultimately increase revenue.

·         Ecommerce Orders Conversion Rate – This tells you what percentage of people that visit your website make a purchase. For an ecommerce focused website, this is likely to be one of your key performance indicators (KPI).

·         Abandoned Carts – The total number and potential revenue of visits where people added products to their shopping cart but ultimately left the site without making a purchase. Matomo also tracks this as a percentage. While this might not reach zero, you should always be aiming to decrease this number.

Internal search tracking

Atrilyx offers advanced Site Search Analytics feature, letting you track how your visitors use your internal website search engine. By default, Atrilyx can read URL parameters that will contain the search keyword. However, you can also record the site search keyword manually using the JavaScript function trackSiteSearch(...)

_paq.push(['trackSiteSearch',

    // Search keyword searched for

    "Banana",

    // Search category selected in your search engine. If you do not need this, set to false

    "Organic Food",

    // Number of results on the Search results page. Zero indicates a 'No Result Search Keyword'. Set to false if you don't know

    0

]);

 

// We recommend not to call trackPageView() on the Site Search Result page

// _paq.push(['trackPageView']);

We also highly recommend setting the searchCount parameter, as Atrilyx will specifically report "No Result Keywords", ie. Keywords that were searched, but did not return any result. It is usually very interesting to know what users search for but can't find (yet?) on your website.

 

Custom variables

Custom variables are a powerful feature that enable you to track custom values for each visit, and/or each page view.

You can set up up to 5 custom variables (name and value) for each visit to your website, and/or up to 5 custom variables for each page view. If you set a custom variable to a visitor, when they come back one hour or two days later, it will be a new visit and their custom variables will be empty.

There are two "scopes" which you can set your custom variables to. The "scope" is the 4th parameter of the function setCustomVariable().

  • when scope = "visit", the custom variable's name and value will be stored in the visit in the database. You can therefore store up to 5 custom variables of scope "visit" for each visit.

  • when scope = "page", the custom variable's name and value will be stored for the page view being tracked. You can therefore store up to 5 custom variables of scope "page" for each page view.

The "index" parameter is the custom variable slot index, an integer from 1 to 5.

Custom variable statistics are reported in Atrilyx under Visitors > custom variables. Both custom variables of scope "visit" and "page" are aggregated in this report.

Custom variables for visits

setCustomVariable(index, name, value, scope = "visit")

This function is used to create, or update a custom variable name and value. For example, imagine you want to store in each visit the gender of the user. You would store the custom variable with a name = "gender", value = "male" or "female".

Important: a given custom variable name must always be stored in the same "index". For example, if you choose to store the variable name = "Gender" in index = 1 and you record another custom variable in index = 1, then the "Gender" variable will be deleted and replaced with the new custom variable stored in index 1.

_paq.push(['setCustomVariable',

    // Index, the number from 1 to 5 where this custom variable name is stored

    1,

    // Name, the name of the variable, for example: Gender, VisitorType

    "Gender",

    // Value, for example: "Male", "Female" or "new", "engaged", "customer"

    "Male",

    // Scope of the custom variable, "visit" means the custom variable applies to the current visit

    "visit"

]);

 

_paq.push(['trackPageView']);

You only need to set a variable with scope "visit" once, and the value will be recorded for the whole visit.

Custom variable for page views

setCustomVariable(index, name, value, scope = "page")

As well as tracking custom variables for "visits", it is sometimes useful to track custom variables for each page view separately. For example, for a "News" website or blog, a given article may be categorized into one or several categories. In this case, you could set one or several custom variables with name="category", one with value="Sports" and another with value="Europe" if the article is classified in Sports and Europe Categories. The custom variables report will then report on how many visits and page views were in each of your website's categories. This information can be difficult to obtain with standard Atrilyx reports because they report on "Best Page URLs" and "Best Page Titles" which might not contain the "category" information.

// Track 2 custom variables with the same name, but in different slots.

// You will then access the statistics about your articles' categories in the 'Visitors &gt; custom variables' report

_paq.push(['setCustomVariable', 1, 'Category', 'Sports', 'page']);

 

// Track the same name but in a different Index

_paq.push(['setCustomVariable', 2, 'Category', 'Europe', 'page']);

// Here you could track other custom variables with scope "page" in Index 3, 4 or 5

// The order is important: first setCustomVariable is called and then trackPageView records the request

 

_paq.push(['trackPageView']);

Important: It is possible to store a custom variables of scope "visit" in "index" 1, and store a different custom variable of scope "page" in the same "index" 1. Therefore, you can technically track up to 10 custom variables names and values on every page of your website (5 with a "page" scope stored in the actual page view, 5 with a "visit" scope stored in the visit).

_paq.push(['setCustomVariable',

    // Index, the number from 1 to 5 where this custom variable name is stored for the current page view

    1,

    // Name, the name of the variable, for example: Category, Sub-category, UserType

    "category",

    // Value, for example: "Sports", "News", "World", "Business", etc.

    "Sports",

    // Scope of the custom variable, "page" means the custom variable applies to the current page view

    "page"

]);

 

_paq.push(['trackPageView']);

Deleting a custom variable

deleteCustomVariable(index, scope)

If you created a custom variable and then decide to remove this variable from a visit or page view, you can use deleteCustomVariable.

To persist the change in the Atrilyx server, you must call the function before the call to trackPageView();

_paq.push(['deleteCustomVariable', 1, "visit"]); // Delete the variable in index 1 stored for the current visit

_paq.push(['trackPageView']);

Retrieving a custom variable

getCustomVariable(index, scope)

This function can be used to get the custom variable name and value. By default, it will only work for custom variables that were set during the same page load.

Note: it is possible to configure Atrilyx so that getCustomVariable will also return the name and value of a custom variable of scope "visit", even when it was set in a previous pageview in the same visit. To enable this behavior, call the JavaScript function storeCustomVariablesInCookie before the call to trackPageView. This will enable the storage of Custom Variables of scope "visit" in a first party cookie. The custom variables cookie will be valid for the duration of the visit (30 minutes after the last action). You can then retrieve the custom variable names and values using getCustomVariable. If there is no custom variable in the requested index, it will return false.

_paq.push([ function() {

 

    var customVariable = this.getCustomVariable( 1, "visit" );

    // Returns the custom variable: [ "gender", "male" ]

 

    // do something with customVariable...

 

}]);

 

_paq.push(['trackPageView']);

Custom Dimensions

Custom Dimensions are a powerful feature that enable you to track custom values for each visit, and/or each action (page view, outlink, download).

You will get a numeric ID for each configured Custom Dimension which can be used to set a value for it.

Tracking a Custom Dimension across tracking requests

To track a value simply specify the ID followed by a value:

_paq.push(['setCustomDimension', customDimensionId = 1, customDimensionValue = 'Member']);

Please note once a Custom Dimension is set, the value will be used for all following tracking requests and may lead to inaccurate results if this is not wanted. For example if you track a page view, the Custom Dimension value will be as well tracked for each following event, outlink, download, etc. within the same page load. Calling this method will not actually trigger a tracking request, instead the values will be sent along with the following tracking requests. To delete a Custom Dimension value after a tracking request call _paq.push(['deleteCustomDimension', customDimensionId]);

Setting a custom dimension for the initial page view

To set a custom dimension for the initial page view, make sure to position the method call setCustomDimension before trackPageView:

_paq.push(['setCustomDimension', customDimensionId = 1, customDimensionValue = 'Member']);

_paq.push(['trackPageView']);

// _paq.push(['enableLinkTracking']);

// rest of tracking code

Tracking a Custom Dimension for one specific action only

It is possible to set a Custom Dimension for one specific action only. If you want to track a Page view, you can send one or more specific Custom Dimension values along with this tracking request as follows:

_paq.push(['trackPageView', pageTitle, {dimension1: 'DimensionValue'}]);

To define a dimension value pass an object defining one or multiple properties as the last parameter (make sure to specify all parameters as defined in the method, we do not automatically assume the last parameter is customData but instead all parameters that a method defines need to be passed to each method). The property name for a dimension starts with dimension followed by a Custom Dimension ID, for example dimension1. The same behaviour applies for several other methods:

_paq.push(['trackEvent', category, action, name, value, {dimension1: 'DimensionValue'}]);

_paq.push(['trackSiteSearch', keyword, category, resultsCount, {dimension1: 'DimensionValue'}]);

_paq.push(['trackLink', url, linkType, {dimension1: 'DimensionValue'}]);

_paq.push(['trackGoal', idGoal, customRevenue, {dimension1: 'DimensionValue'}]);

The advantage is that the set dimension value will be only used for this particular action and you do not have to delete the value after a tracking request. You may set multiple dimension values like this:

_paq.push(['trackPageView', pageTitle, {dimension1: 'DimensionValue', dimension4: 'Test', dimension7: 'Value'}]);

Retrieving a Custom Dimension value

getCustomDimension(customDimensionId)

This function can be used to get the value of a Custom Dimension. It will only work if a Custom Dimension was set during the same page load.

User ID

User ID is a feature in Atrilyx that lets you connect together a given user's data collected from multiple devices and multiple browsers. There are two steps to implementing User ID:

  • You must assign a unique and persistent non-empty string that represents each logged-in user. Typically, this ID will be an email address or a username provided by your authentication system.

  • You must set the user ID for each pageview, otherwise the pageview will be tracked without the user ID set.

  • You must then pass this User ID string to Atrilyx via the setUserId method call just before calling any of the track* functions (trackPageview, trackEvent, trackGoal, trackSiteSearch, etc.) for example:

_paq.push(['setUserId', 'USER_ID_HERE']);

_paq.push(['trackPageView']);

Note: USER_ID_HERE must be a unique and persistent non-empty string that represents a user across devices.

When user is logged in, set the User ID

Let's take an example. Imagine that your website authenticate your users via a login form using a PHP script. Here is what your Atrilyx JavaScript snippet may look like:

var _paq = window._paq = window._paq || [];

 

<?php

// If user is logged-in then call 'setUserId'

// $userId variable must be set by the server when the user has successfully authenticated to your app.

if (isset($userId)) {

     echo sprintf("_paq.push(['setUserId', '%s']);", $userId);

}

?>

 

_paq.push(['trackPageView']);

_paq.push(['enableLinkTracking']);

When user logs out, reset User ID

When the user has logged out and a User ID is not available anymore, it is recommended to notify Atrilyx by calling the resetUserId method before trackPageView.

If you want to create a new visit when your users logout, then you can also force Atrilyx to create a new Visit by calling resetUserId and appendToTrackingUrl (twice) as below:

 

// User has just logged out, we reset the User ID

_paq.push(['resetUserId']);

 

// we also force a new visit to be created for the pageviews after logout

_paq.push(['appendToTrackingUrl', 'new_visit=1']);

 

_paq.push(['trackPageView']);

 

// we finally make sure to not again create a new visit afterwards (important for Single Page Applications)

_paq.push(['appendToTrackingUrl', '']);

 

Content Tracking

There are several ways to track content impressions and interactions manually, semi-automatically and automatically. Please be aware that content impressions will be tracked using bulk tracking which will always send a POST request, even if GET is configured which is the default.

Track all content impressions within a page

You can use the method trackAllContentImpressions() to scan the entire DOM for content blocks. For each content block we will track a content impression immediately. If you only want to track visible content impression have a look at trackVisibleContentImpressions().

_paq.push(['trackPageView']);

_paq.push(['trackAllContentImpressions']);

We won't send an impression of the same content block twice if you call this method multiple times unless trackPageView() is called meanwhile. This is useful for single page applications.

Track only visible content impressions within a page.

Enable to track only visible content impressions via trackVisibleContentImpressions(checkOnScroll, timeIntervalInMs). With visible we mean the content block has been in the view port and is not hidden (opacity, visibility, display, ...).

  • Optionally you can tell us to not rescan the DOM after each scroll by passing checkOnScroll=false. Otherwise, we will check whether the previously hidden content blocks became visible meanwhile after a scroll and if so track the impression.

    • Limitation: If a content block is placed within a scrollable element (overflow: scroll), we do currently not detect when such an element becomes visible.

  • Optionally you can tell us to rescan the entire DOM for new content impressions every X milliseconds by passing timeIntervalInMs=500. By default, we will rescan the DOM every 750ms. To disable it pass timeIntervalInMs=0.

    • Rescanning the entire DOM and detecting the visible state of content blocks can take a while depending on the browser, hardware and amount of content. In case your frames per second goes down you might want to increase the interval or disable it completely. In case you disable it you can still rescan the DOM manually at any time by calling this method again or trackContentImpressionsWithinNode().

Both checkOnScroll and timeIntervalInMs cannot be changed after this method was called the first time.

_paq.push(['trackPageView']);

_paq.push(['trackVisibleContentImpressions', true, 750]);

Track content impressions only for a part of the page

Use the method trackContentImpressionsWithinNode(domNode, contentTarget) if you are adding elements to your DOM after we have tracked the initial impressions. Calling this method will make sure an impression will be tracked for all content blocks contained within this node.

Example

var div = $('<div>...<div data-track-content>...</div>...<div data-track-content>...</div></div>');

$('#id').append(div);

 

_paq.push(['trackContentImpressionsWithinNode', div[0]]);

We would detect two new content impressions in this example. In case you have enabled to track only visible content blocks we will respect this.

Track an interaction semi-automatic

Interactions with content blocks are usually tracked automatically as soon as a visitor is clicking on it. Sometimes you might want to trigger an interaction manually for instance in case you want to trigger an interaction based on a form submit or a double click. To do so call the method trackContentInteractionNode(domNode, contentInteraction).

Example

formElement.addEventListener('submit', function () {

    _paq.push(['trackContentInteractionNode', this, 'submittedForm']);

});

  • The passed domNode can be any node within a content block or the content block element itself. Nothing will be tracked in case there is no content block found.

  • Optionally you can set the name of the content interaction, for instance click or submit. If none is provided, the value Unknown will be used.

  • You should disable the automatic interaction tracking of that content block by setting the CSS class piwikContentIgnoreInteraction or the attribute data-content-ignoreinteraction. Otherwise an interaction might be tracked on top of it as soon as a visitor performs a click.

We call this kind of tracking semi-automatic as you triggered the interaction manually but the content name, piece and target is detected automatically. Detecting the content name and piece automatically makes sure we can map the interaction with a previously tracked impression.

Tracking content impressions and interactions manually

You should use the methods trackContentImpression(contentName, contentPiece, contentTarget) and trackContentInteraction( contentInteraction, contentName, contentPiece, contentTarget) only in conjunction together. It is not recommended to use trackContentInteraction() after an impression was tracked automatically as we can map an interaction to an impression only if you do set the same content name and piece that was used to track the related impression.

Example

_paq.push(['trackContentImpression', 'Content Name', 'Content Piece', 'https://www.example.com ']);

 

div.addEventListener('click', function () {

    _paq.push(['trackContentInteraction', 'tabActivated', 'Content Name', 'Content Piece', 'https://www.example.com ']);

});

Be aware that each call to those methods will send one request to your Atrilyx tracker instance. Doing this too many times can cause performance problems.

Measuring domains and/or sub-domains

Whether you are tracking one domain, or a subdomain, or both at the same time, etc. you may need to configure the Atrilyx JavaScript tracking code. There are two things that may need to be configured: 1) how tracking cookies are created and shared, and 2) which clicks should be tracked as 'Outlinks'.

Tracking one domain

This is the standard use case. Atrilyx tracks the visits of one domain name with no subdomain, in a single Atrilyx website.

// Default Tracking code

_paq.push(['setSiteId', 1]);

_paq.push(['setTrackerUrl', u+'Atrilyx.php']);

_paq.push(['trackPageView']);

If you are tracking one specific subdomain, this default tracking code also works.

Tracking one domain and its subdomains in the same website

To record users across the main domain name and any of its subdomains, we tell Atrilyx to share the cookies across all subdomains. setCookieDomain() is called in the Atrilyx tracking code in example.com/* and all subdomains.

_paq.push(['setSiteId', 1]);

_paq.push(['setTrackerUrl', u+'Atrilyx.php']);

 

// Share the tracking cookie across http://example.com , http://www.example.com , subdomain.example.com, ...

_paq.push(['setCookieDomain', '*.example.com']);

 

// Tell Atrilyx the website domain so that clicks on these domains are not tracked as 'Outlinks'

_paq.push(['setDomains', '*.example.com']);

 

_paq.push(['trackPageView']);

Tracking your visitors across multiple domain names in the same website

To accurately track a visitor across different domain names into a single visit within one Atrilyx website, we need to set up what is called Cross Domain linking. Cross domain tracking in Atrilyx makes sure that when the visitor visits multiple websites and domain names, the visitor data will be stored in the same visit and that the visitor ID is reused across domain names. A typical use case where cross domain is needed is, for example, when an ecommerce online store is on www.awesome-shop.com and the ecommerce shopping cart technology is on another domain such as secure.cart.com.

Cross domain linking uses a combination of the two tracker methods setDomains and enableCrossDomainLinking

Tracking subdirectories of a domain in separate websites

When tracking subdirectories of a domain in their own separate Atrilyx website, it is recommended to customise the tracking code to ensure optimal data accuracy and performance.

For example, if your website offers a 'User profile' functionality, you may wish to track each user profile pages in a separate website in Atrilyx. In the main domain homepage, you would use the default tracking code:

// idSite = X for the Homepage

// In Administration > Websites for idSite=X, the URL is set to `example.com/`

_paq.push(['setSiteId', X]);

_paq.push(['setTrackerUrl', u+'Atrilyx.php']);

_paq.push(['trackPageView']);

In the example.com/user/MyUsername page (and in every other user profile), you would construct calls to custom setSiteId, setCookiePath and setDomains:

// The idSite Y will be different from other user pages

// In Administration > Websites for idSite=Y, the URL is set to `example.com/user/MyUsername`

_paq.push(['setSiteId', Y]);

 

// Create the tracking cookie specifically in `example.com/user/MyUsername`

_paq.push(['setCookiePath', '/user/MyUsername']);

 

// Tell Atrilyx the website domain so that clicks on other pages (eg. /user/AnotherUsername) will be tracked as 'Outlinks'

_paq.push(['setDomains', 'example.com/user/MyUsername']);

 

_paq.push(['setTrackerUrl', u+'Atrilyx.php']);

_paq.push(['trackPageView']);

When tracking many subdirectories in separate websites, the function setCookiePath prevents the number of cookies to quickly increase and prevent browser from deleting some of the cookies. This ensures optimal data accuracy and improves performance for your users (fewer cookies are sent with each request).

The functionsetDomains ensures that clicks of users leaving your website (subdirectory example.com/user/MyUsername) are correctly tracked as 'Outlinks'.

Tracking a group of pages in a separate website

In some rare cases, you may want to track all pages matching a wildcard in a particular website, and track clicks on other pages (not matching the wildcard) as 'Outlinks'.

In the pages /index_fr.htm or /index_en.htm write:

// clicks on links not starting with example.com/index will be tracked as 'Outlinks'

_paq.push(['setDomains', 'example.com/index*']);

 

// when using a wildcard *, we do not need to configure cookies with `setCookieDomain`

// or `setCookiePath` as cookies are correctly created in the main domain by default

 

_paq.push(['setTrackerUrl', u+'Atrilyx.php']);

_paq.push(['trackPageView']);

Notes:

  • the wildcard * is supported only when specified at the end of the string.

  • since the wildcard can match several paths, calls to setCookieDomain or setCookiePath are omitted to ensure tracking cookie is correctly shared for all pages matching the wildcard.

Download and Outlink tracking

Enabling Download & Outlink tracking

The default Atrilyx JavaScript tracker code automatically enables the download & outlink tracking automatically, which is done by calling the enableLinkTracking function:

 

// Enable Download & Outlink tracking

_paq.push(['enableLinkTracking']);

 

It is recommended to add this line just after the first call to trackPageView or trackEvent.

Outlinks are tracked automatically

By default all links to domains other than the current domain have click tracking enabled, and each click will be counted as an outlink. If you use multiple domains and subdomains, you may see clicks on your subdomains appearing in the Pages > Outlinks report.

Tracking outlinks and ignore alias domains

If you only want clicks to external websites to appear in your outlinks report, you can use the function setDomains() to specify the list of alias domains or subdomains. Wildcard domains (*.example.org) are supported to let you easily ignore clicks to all subdomains.

// Don't track Outlinks on all clicks pointing to *.hostname1.com or *.hostname2.com

// Note: the currently tracked website is added to this array automatically

_paq(['setDomains', ["*.hostname1.com", "http://hostname2.com "]]);

 

_paq.push(['trackPageView']);

Since Atrilyx 2.15.1 you may also append a path to a domain and Atrilyx will correctly detect links to the same domain but different path as an outlink.

// Don't track Outlinks on all clicks pointing to *.hostname1.com/product1/* or *.hostname2.com/product1/*

// Track all clicks not pointing to *.hostname1.com/product1/* or *.hostname2.com/product1/* as outlink.

_paq(['setDomains', ["*.hostname1.com/product1", "http://hostname2.com/product1 "]]);

Tracking a click as an outlink via CSS or JavaScript

If you want to force Atrilyx to consider a link as an outlink (links to the current domain or to one of the alias domains), you can add the Atrilyx_link or piwik_link css class to the link:

<a href='https://mysite.com/partner/' class='Atrilyx_link'>Link I want to track as an outlink</a>

Note: you can customize and rename the CSS class used to force a click to be recorded as an outlink:

// now all clicks on links with the css class "external" will be counted as outlinks

 

// you can also pass an array of strings

_paq.push(['setLinkClasses', "external"]);

 

_paq.push(['trackPageView']);

Alternatively, you can use JavaScript to manually trigger a click on an outlink (it will work the same for page views or file downloads). In this example, custom outlink is trigged when the email address is clicked:

<a href="mailto:namexyz@mydomain.co.uk" target="_blank" onClick="_paq.push(['trackLink', 'https://mydomain.co.uk/mailto/Agent namexyz', 'link']);">namexyz@mydomain.co.uk </a>

Tracking file downloads

By default, any file ending with one of these extensions will be considered a 'download' in the Atrilyx interface:

7z|aac|arc|arj|apk|asf|asx|avi|bin|bz|bz2|csv|deb|dmg|doc|

exe|flv|gif|gz|gzip|hqx|jar|jpg|jpeg|js|mp2|mp3|mp4|mpg|

mpeg|mov|movie|msi|msp|odb|odf|odg|odp|ods|odt|ogg|ogv|

pdf|phps|png|ppt|qt|qtm|ra|ram|rar|rpm|sea|sit|tar|

tbz|tbz2|tgz|torrent|txt|wav|wma|wmv|wpd||xls|xml|z|zip

Customise the type of files tracked as downloaded

To replace the list of extensions you want to track as file downloads, you can use setDownloadExtensions( string ):

// we now only track clicks on images

_paq.push(['setDownloadExtensions', "jpg|png|gif"]);

 

_paq.push(['trackPageView']);

If you want to track a new file type, you can just add it to the list by using addDownloadExtensions( filetype ):

// clicks on URLs finishing by mp5 or mp6 will be counted as downloads

_paq.push(['addDownloadExtensions', "mp5|mp6"]);

_paq.push(['trackPageView']);

If you want to ignore a special file type, you can just remove it from the list by using removeDownloadExtensions( filetype ):

// clicks on URLs ending in png or mp4 will not be counted as downloads

_paq.push(['removeDownloadExtensions', "png|mp4"]);

_paq.push(['trackPageView']);

Recording a click as a download

If you want to force Atrilyx to consider a link as a download, you can add the Atrilyx_download or piwik_download css class to the link:

<a href='last.php' class='Atrilyx_download'>Link I want to track as a download</a>

Note: you can customize and rename the CSS class used to force a click to be recorded as a download:

// now all clicks on links with the css class "download" will be counted as downloads

 

// you can also pass an array of strings

_paq.push(['setDownloadClasses', "download"]);

 

_paq.push(['trackPageView']);

Alternatively, you can use JavaScript to manually trigger a click on a download. In this example, custom download is trigged when the link is clicked:

<a href="https://secure.example.com/this-is-a-file-url" target="_blank" onClick="_paq.push(['trackLink', 'https://mydomain.co.uk/mailto/Agent namexyz', 'download']);">Download</a>

Changing the Pause Timer

When a user clicks to download a file, or clicks on an outbound link, Atrilyx records it. In order to do so, it adds a small delay before the user is redirected to the requested file or link. The default value is 500ms, but you can set it to a shorter length of time. It should be noted, however, that doing so results in the risk that this period of time is not long enough for the data to be recorded in Atrilyx.

_paq.push(['setLinkTrackingTimer', 250]); // 250 milliseconds

 

_paq.push(['trackPageView']);

Disabling Download & Outlink tracking

By default, the Atrilyx tracking code enables clicks and download tracking. To disable all automatic download and outlink tracking, you must remove the call to the enableLinkTracking() function:

_paq.push(['trackPageView']);

 

// we comment out the function that enables link tracking

// _paq.push(['enableLinkTracking']);

Disabling for specific CSS classes

You can disable automatic download and outlink tracking for links with specific CSS classes:

 // you can also pass an array of strings

_paq.push(['setIgnoreClasses', "no-tracking"]);

_paq.push(['trackPageView']);

This will result in clicks on a link <a href='https://example.com ' class='no-tracking'>Test</a> not being counted.

Disabling for a specific link

If you want to ignore download or outlink tracking on a specific link, you can add the Atrilyx_ignore or 'piwik_ignore' css class to it:

<a href='https://builds.Atrilyx.org/latest.zip' class='Atrilyx_ignore'>File I don't want to track as a download</a>

Asking for consent

Optional: creating a custom opt-out form

If you'd like to provide your users with the ability to opt-out entirely from tracking, you can use an opt-out form. Atrilyx ships with an opt-out form implementation that uses third-party cookies (which you can configure within Atrilyx on the Atrilyx > Administration > Privacy page).

This form is simple to embed since it only requires that you add an iframe to your website, but it is not always ideal. Some users block third-party cookies so the opt-out form wouldn't work for them. You may also want to display custom text or graphics in the opt-out form, or you may want to allow users to opt-out of your sites individually instead of altogether.

In such a case, you may want to consider creating a custom opt-out form. The specifics of creating an HTML/JS form are out of scope for this document, but there are some things every custom opt-out form will have to do: check if the user is currently opted out, opt a user out and opt a user in. Here is how to do those things:

check if the user is currently opted out

Use the isUserOptedOut() method like so:

_paq.push([function () {

  if (this.isUserOptedOut()) {

    // ... change form to say user is currently opted out ...

  } else {

    // ... change form to say user is currently opted in ...

  }

}])

opt a user out

Use the optUserOut() method:

_paq.push(['optUserOut']);

opt a user in

Use the forgetUserOptOut() method:

_paq.push(['forgetUserOptOut']);

Below is an example opt-out form that replicates the built in Atrilyx opt-out form:

<div id="optout-form">

  <p>You may choose not to have a unique web analytics cookie identification number assigned to your computer to avoid the aggregation and analysis of data collected on this website.</p>

  <p>To make that choice, please click below to receive an opt-out cookie.</p>

 

  <p>

    <input type="checkbox" id="optout" />

    <label for="optout"><strong></strong></label>

  </p>

</div>

<script>

document.addEventListener("DOMContentLoaded", function(event) {

  function setOptOutText(element) {

    _paq.push([function() {

      element.checked = !this.isUserOptedOut();

      document.querySelector('label[for=optout] strong').innerText = this.isUserOptedOut()

        ? 'You are currently opted out. Click here to opt in.'

        : 'You are currently opted in. Click here to opt out.';

    }]);

  }

 

  var optOut = document.getElementById("optout");

  optOut.addEventListener("click", function() {

    if (this.checked) {

      _paq.push(['forgetUserOptOut']);

    } else {

      _paq.push(['optUserOut']);

    }

    setOptOutText(optOut);

  });

  setOptOutText(optOut);

});

</script>

</script>

 

List of all Methods Available in the Tracking API

Using the Tracker Object

  • trackPageView([customTitle]) - Log a page view

  • trackEvent(category, action, [name], [value]) - Log an event with an event category (Videos, Music, Games...), an event action (Play, Pause, Duration, Add Playlist, Downloaded, Clicked...), and an optional event name and optional numeric value.

  • trackSiteSearch(keyword, [category], [resultsCount]) - Log an internal site search for a specific keyword, in an optional category, specifying the optional count of search results in the page.

  • trackGoal( idGoal, [customRevenue]); - Log a conversion for the numeric goal ID, with an optional numeric custom revenue customRevenue.

  • trackLink( url, linkType ) - Log a click from your own code. url is the full URL which is to be tracked as a click. linkType can either be 'link' for an outlink or 'download' for a download.

  • trackAllContentImpressions() - Scan the entire DOM for all content blocks and tracks all impressions once the DOM ready event has been triggered.

  • trackVisibleContentImpressions ( checkOnScroll, timeIntervalInMs ) - Scan the entire DOM for all content blocks as soon as the page is loaded. It tracks an impression only if a content block is actually visible.

  • trackContentImpressionsWithinNode( domNode ) - Scan the given DOM node and its children for content blocks and tracks an impression for them if no impression was already tracked for it.

  • trackContentInteractionNode( domNode, contentInteraction ) - Track an interaction with the given DOM node / content block.

  • trackContentImpression( contentName, contentPiece, contentTarget ) - Track a content impression using the specified values.

  • trackContentInteraction( contentInteraction, contentName, contentPiece, contentTarget ) - Track a content interaction using the specified values.

  • logAllContentBlocksOnPage() - Log all found content blocks within a page to the console. This is useful to debug / test content tracking.

  • ping() - Send a ping request. Ping requests do not track new actions. If they are sent within the standard visit length, they will update the existing visit time. If sent after the standard visit length, ping requests will be ignored. See also enableHeartBeatTimer.

  • enableHeartBeatTimer( activeTimeInseconds ) - Install a Heart beat timer that will send additional requests to Atrilyx in order to better measure the time spent in the visit. These requests will be sent only when the user is actively viewing the page (when the tab is active and in focus). These requests will not track additional actions or pageviews. By default, activeTimeInSeconds is set to 15 seconds. Meaning only if the page was viewed for at least 15 seconds (and the user leaves the page or focuses away from the tab) then a ping request will be sent.

  • enableLinkTracking( enable ) - Install link tracking on all applicable link elements. Set the enable parameter to true to use pseudo click-handler (treat middle click and open contextmenu as left click). A right click (or any click that opens the context menu) on a link will be tracked as clicked even if "Open in new tab" is not selected. If "false" (default), nothing will be tracked on open context menu or middle click.

  • enableFileTracking() - Enable tracking of file:// protocol actions. By default, the file:// protocol is not tracked.

  • disablePerformanceTracking - Disables page performance tracking.

  • enableCrossDomainLinking() - Enable cross domain linking. By default, the visitor ID that identifies a unique visitor is stored in the browser's first party cookies. This means the cookie can only be accessed by pages on the same domain. If you own multiple domains and would like to track all the actions and pageviews of a specific visitor into the same visit, you may enable cross domain linking. Whenever a user clicks on a link it will append a URL parameter pk_vid to the clicked URL which forwards the current visitor ID value to the page of the different domain.

  • setCrossDomainLinkingTimeout( timeout ) - Set the cross domain linking timeout (in seconds). By default, the two visits across domains will be linked together when the link is clicked and the page is loaded within a 180 seconds timeout window.`

  • getCrossDomainLinkingUrlParameter() - Get the query parameter to append to links to handle cross domain linking. Use this to add cross domain support for links that are added to the DOM dynamically.

  • disableBrowserFeatureDetection() - By default, Atrilyx accesses information from the visitor's browser to detect the current browser resolution and what browser plugins (for example PDF and cookies) are supported. This information is used to show you reports on your visitor's browser resolution, supported browser plugins, and it is also used to generate a short-lived identifier for every visitor which we call the config_id. Some privacy regulations may only allow accessing information from a visitor's device after having consent. If this applies to you, call this method to no longer access this information.

  • enableBrowserFeatureDetection() - Enable the browser feature detection if you previously disabled it.

Configuration of the Tracker Object

  • setDocumentTitle( string ) - Override document.title

  • setDomains( array ) - Set array of hostnames or domains to be treated as local. For wildcard subdomains, you can use: setDomains('.example.com'); or setDomains('*.example.com');. You can also specify a path along a domain: setDomains('*.example.com/subsite1');

  • setCustomUrl( string ) - Override the page's reported URL

  • setReferrerUrl( string ) - Override the detected Http-Referer. We recommend you call this method early in your tracking code before you call trackPageView if it should be applied to all tracking requests.

  • setExcludedReferrers( string | array ) - Set array of hostnames or domains that should be ignored as referrers. For wildcard subdomains, you can use: setExcludedReferrers('.example.com'); or setExcludedReferrers('*.example.com');. You can also specify a path along a domain: setExcludedReferrers('*.example.com/subsite1');. This method is available as of Atrilyx 4.12.

  • getExcludedReferrers() - Returns the list of excluded referrers, which was previously set using setExcludedReferrers.

  • setSiteId( integer ) - Specify the website ID. Redundant: can be specified in getTracker() constructor.

  • setApiUrl( string ) - Specify the Atrilyx HTTP API URL endpoint. Points to the root directory of Atrilyx, e.g. https://Atrilyx.example.org/ or https://example.org/Atrilyx/. This function is only useful when the 'Overlay' report is not working. By default, you do not need to use this function.

  • setTrackerUrl( string ) - Specify the Atrilyx server URL. Redundant: can be specified in getTracker() constructor.

  • getAtrilyxUrl() - Return the Atrilyx server URL.

  • getPiwikUrl() - Deprecated, use getAtrilyxUrl() instead.

  • getCurrentUrl() - Return the current url of the page that is currently being visited. If a custom URL was set before calling this method, the custom URL will be returned.

  • setDownloadClasses( string | array ) - Set classes to be treated as downloads (in addition to Atrilyx_download)

  • setDownloadExtensions( string | array ) - Set list of file extensions to be recognized as downloads. Example: 'doc' or ['doc', 'xls']

  • addDownloadExtensions( string | array ) - Specify additional file extensions to be recognized as downloads. Example: 'doc' or ['doc', 'xls']

  • removeDownloadExtensions( string | array ) - Specify file extensions to be removed from the list of download file extensions. Example: 'doc' or ['doc', 'xls']

  • setIgnoreClasses( string | array ) - Set classes to be ignored if present in link (in addition to Atrilyx_ignore and piwik_ignore)

  • setLinkClasses( string | array ) - Set classes to be treated as outlinks (in addition to piwik_link)

  • setLinkTrackingTimer( integer ) - Set delay for link tracking in milliseconds.

  • getLinkTrackingTimer() - Get delay for link tracking (in milliseconds).

  • discardHashTag( bool ) - Set to true to not record the hash tag (anchor) portion of URLs

  • appendToTrackingUrl(appendToUrl) - Append a custom string to the end of the HTTP request to Atrilyx.php?

  • setDoNotTrack( bool ) - Set to true to not track users who opt out of tracking using Mozilla's (proposed) Do Not Track setting.

  • killFrame() - Enable a frame-buster to prevent the tracked web page from being framed/iframed.

  • redirectFile( url ) - Force the browser load the live URL if the tracked web page is loaded from a local file (e.g., saved to someone's desktop).

  • setHeartBeatTimer( minimumVisitLength, heartBeatDelay ) - Record how long the page has been viewed if the minimumVisitLength (in seconds) is attained; the heartBeatDelay determines how frequently to update the server

  • getVisitorId() - Return the 16 characters ID for the visitor

  • setVisitorId( visitorId ) - visitorId needs to be a 16 digit hex string. The visitorId won't be persisted in a cookie and needs to be set on every new page load.

  • getVisitorInfo() - Return the visitor cookie contents in an array

  • getAttributionInfo() - Return the visitor attribution array (Referer information and / or Campaign name & keyword). Attribution information is used by Atrilyx to credit the correct referrer used when a user triggers a goal conversion.

  • getUserId() - Return the User ID string if it was set.

  • setUserId( userId ) - Sets a User ID to this user (such as an email address or a username).

  • resetUserId - Clears (un-set) the User ID.

  • setCustomVariable (index, name, value, scope) - Set a custom variable.

  • deleteCustomVariable (index, scope) - Delete a custom variable.

  • getCustomVariable (index, scope) - Retrieve a custom variable.

  • storeCustomVariablesInCookie() - When called then the Custom Variables of scope "visit" will be stored (persisted) in a first party cookie for the duration of the visit. This is useful if you want to call getCustomVariable later in the visit. (by default custom variables are not stored on the visitor's computer.)

  • setCustomDimension (customDimensionId, customDimensionValue) - Set a custom dimension.

  • deleteCustomDimension (customDimensionId) - Delete a custom dimension

  • getCustomDimension (customDimensionId) - Retrieve a custom dimension.

  • setCampaignNameKey(name) - Set campaign name parameter(s).

  • setCampaignKeywordKey(keyword) - Set campaign keyword parameter(s). (Help:

  • setConversionAttributionFirstReferrer( bool ) - Set to true to attribute a conversion to the first referrer. By default, conversion is attributed to the most recent referrer.

Ecommerce

Atrilyx provides ecommerce analytics that let you measure items added to carts, and learn detailed metrics about abandoned carts and purchased orders.

setEcommerceView( productSKU, productName, categoryName, price ) - Set the current page view as a product or category page view. When you call setEcommerceView it must be followed by a call to trackPageView to record the product or category page view.

  • addEcommerceItem( productSKU, [productName], [productCategory], [price], [quantity] ) - Add a product into the ecommerce order. Must be called for each product in the order.

  • removeEcommerceItem( productSKU ) - Remove the specified product from the untracked ecommerce order.

  • clearEcommerceCart() - Remove all products in the untracked ecommerce order. _Note: this is done automatically after trackEcommerceOrder() is called.

  • getEcommerceItems() - Return all ecommerce items currently in the untracked ecommerce order. The returned array will be a copy, so changing it won't affect the ecommerce order. To affect what gets tracked, use the addEcommerceItem()/removeEcommerceItem()/clearEcommerceCart() methods. Use this method to see what will be tracked before you track an order or cart update.

  • trackEcommerceCartUpdate( grandTotal ) - Track a shopping cart. Call this javascript function every time a user is adding, updating or deleting a product from the cart.

  • trackEcommerceOrder( orderId, grandTotal, [subTotal], [tax], [shipping], [discount] ) - Track an Ecommerce order, including any ecommerce item previously added to the order. orderId and grandTotal (ie. revenue) are required parameters.

Managing Consent

Atrilyx provides a mechanism to manage your user's tracking consent. You can require that users consent before you track any of their actions, disable tracking for users that do not consent, and re-enable tracking for those that consent later. No cookies will be used when no consent is given. Once consent is given, cookies will be used.

  • requireConsent() - By default the Atrilyx tracker assumes consent to tracking. To change this behavior so nothing is tracked until a user consents, you must call requireConsent.

  • setConsentGiven() - Mark that the current user has consented. The consent is one-time only, so in a subsequent browser session, the user will have to consent again. To remember consent, see the method below: rememberConsentGiven.

  • rememberConsentGiven( hoursToExpire ) - Mark that the current user has consented, and remembers this consent through a browser cookie. The next time the user visits the site, Atrilyx will remember that they consented, and track them. If you call this method, you do not need to call setConsentGiven.

  • forgetConsentGiven() - Remove a user's consent, both if the consent was one-time only and if the consent was remembered. After calling this method, the user will have to consent again in order to be tracked.

  • hasRememberedConsent() - Returns true or false depending on whether the current visitor has given consent previously or not.

  • getRememberedConsent() - If consent was given, returns the timestamp when the visitor gave consent. Only works if rememberConsentGiven was used and not when setConsentGiven was used. The timestamp is the local timestamp which depends on the visitors time.

  • isConsentRequired() - Returns true or false depending on whether requireConsent was called previously.

Atrilyx also provides a mechanism to manage your user's cookie consent. You can require that users consent to using cookies. Tracking requests will be always sent but depending on the consent cookies will be used or not used.

  • requireCookieConsent() - By default the Atrilyx tracker assumes consent to using cookies. To change this behavior so no cookies are used by default, you must call requireCookieConsent.

  • setCookieConsentGiven() - Mark that the current user has consented to using cookies. The consent is one-time only, so in a subsequent browser session, the user will have to consent again. To remember cookie consent, see the method below: rememberCookieConsentGiven.

  • rememberCookieConsentGiven( hoursToExpire ) - Mark that the current user has consented to using cookies, and remembers this consent through a browser cookie. The next time the user visits the site, Atrilyx will remember that they consented, and use cookies. If you call this method, you do not need to call setCookieConsentGiven.

  • forgetCookieConsentGiven() - Remove a user's cookie consent, both if the consent was one-time only and if the consent was remembered. After calling this method, the user will have to consent again in order for cookies to be used.

  • areCookiesEnabled() - Returns true or false depending on whether cookies are currently enabled or disabled.

  • getRememberedCookieConsent() - If cookie consent was given, returns the timestamp when the visitor gave consent. Only works if rememberCookieConsentGiven was used and not when setCookieConsentGiven was used. The timestamp is the local timestamp which depends on the visitors time.

Configuration of Tracking Cookies

Atrilyx uses first party cookies to keep track of some user information over time. Consideration must be given to retention times and avoiding conflicts with other cookies, trackers, and apps.

  • disableCookies() - Disable all first party cookies. Existing Atrilyx cookies for this website will be deleted on the next page view. Cookies will be even disabled if the user has given cookie consent using the method rememberCookieConsentGiven().

  • deleteCookies() - Delete the tracking cookies currently set

  • hasCookies() - Return whether cookies are enabled and supported by this browser.

  • setCookieNamePrefix( prefix ) - the default prefix is 'pk'.

  • setCookieDomain( domain ) - the default is the document domain; if your website can be visited at both http://www.example.com and http://example.com , you would use: tracker.setCookieDomain('.example.com'); or tracker.setCookieDomain('*.example.com');

  • setCookiePath( path ) - the default is '/'.

  • setSecureCookie( bool ) - set to true to enable the Secure cookie flag on all first party cookies. This should be used when your website is only available under HTTPS so that all tracking cookies are always sent over secure connection.

  • setCookieSameSite( string ) - defaults to Lax. Can be set to None or Strict. None requires all traffic to be on HTTPS and will also automatically set the secure cookie. It can be useful for example if the tracked website is an iframe. Strict only works if your Atrilyx and the website runs on the very same domain.

  • setVisitorCookieTimeout( seconds ) - the default is 13 months

  • setReferralCookieTimeout( seconds ) - the default is 6 months

  • setSessionCookieTimeout( seconds ) - the default is 30 minutes

Advanced uses

  • addListener( element ) - Add click listener to a specific link element. When clicked, Atrilyx will log the click automatically.

  • setRequestMethod( method ) - Set the request method to either "GET" or "POST". To use the POST request method, either 1) the Atrilyx host is the same as the tracked website host (Atrilyx installed in the same domain as your tracked website), or 2) if Atrilyx is not installed on the same host as your website, you need to enable CORS (Cross domain requests). Keep in mind that when Atrilyx uses sendBeacon() for sending tracking requests (which is enabled by default), it will send data via POST. If you want Atrilyx to never send POST requests, you can use this method to force GET which will automatically disable sendBeacon.

  • disableAlwaysUseSendBeacon() - Disables sending tracking tracking requests using navigator.sendBeacon which is enabled by default.

  • setCustomRequestProcessing( function ) - Set a function that will process the request content. The function will be called once the request (query parameters string) has been prepared, and before the request content is sent.

  • setRequestContentType( contentType ) - Set request Content-Type header value. Applicable when "POST" request method is used via setRequestMethod.

  • disableQueueRequest() - Disable the feature which groups together multiple tracking requests and send them as a bulk POST request. one must use disableQueueRequest to disable this behaviour to later be able to replay logged Atrilyx logs (otherwise a subset of the requests wouldn't be able to be replayed).

  • setRequestQueueInterval( interval ) - Defines after how many ms a queued requests will be executed after the request was queued initially. The higher the value the more tracking requests can be sent together at once. interval has to be at least 1000 (1000ms = 1s) and defaults to 2.5 seconds.

  • setPagePerformanceTiming([networkTimeInMs], [serverTimeInMs], [transferTimeInMs], [domProcessingTimeInMs], [domCompletionTimeInMs], [onloadTimeInMs]) - Manually set performance metrics in milliseconds in a Single Page App or when Atrilyx cannot detect some metrics. You can set parameters to undefined if you do not want to track this metric. At least one parameter needs to be set. The set performance timings will be tracked only on the next page view. If you track another page view then you will need to set the performance timings again. Requires Atrilyx 4.5 or newer.

Unit Tests Covering Atrilyx.js

The Atrilyx JavaScript Tracking API is covered by an extensive JavaScript unit test suite to ensure that the code quality is as high as possible, and that we never break this functionality. Tests are written using QUnit.

The Atrilyx JavaScript API has been tested with numerous web browsers. To maximize coverage, we use services like crossbrowsertesting.com and browsershots.org.

Minify Atrilyx.js

The Atrilyx.js is minified to reduce the size that your website visitors will have to download. The YUI Compressor is used to minify the JavaScript.

 

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.