analytics.js Deprecated

Quick start

This tutorial will help you to start sending data from your website to EPICA and any of our integrations, using our Analytics.js library.

Step 1: Copy the Snippet

Installing EPICA is easy, just paste this code snippet between the <head> and </head> tags of your web page:

<script type="text/javascript">
!function(P,o,d,e,r,I,O){function f(q, n){q[n]=function(){return q.push([n].concat([],q}}
if("poder.IO pixel included twice.");else{for([],
'//'+e+'/analytics.min.js';O=o.getElementsByTagName(d)[0];O.parentNode.insertBefore(I, O)}

NOTE: You may already have other existing code between the <head> tags, so just place the pixel code underneath that, but above </head>.

When you paste it, you’ll need to replace YOUR_WRITE_KEY with your EPICA project’s Write Key, which is provided by our customer success team.

That’s it! The basic setup is finished and you are tracking page views now.

NOTE: The snippet loads analytics.js asynchronously but already provides you an access to analytics.js API. So it won’t affect your page load speed and allows you to call analytics.js API methods while analytics.js is still being loaded.

Step 2: Identify Users

By default we automatically assign an anonymousId to all visitors. This is how we know that for example page and track events came from the same visitor.

To tell EPICA more about your know users, call User ID and any optional traits to identify method.

An example how you would sent data about the user who is recognised in you system by ID 'f02321dka' and whose name and email you already know:

analytics.identify('f02321dka', {
name: 'Max Fresh',
email: ''

To provide actual user data to identify API call you may use two strategies:

Step 3: Track Actions

To tell EPICA more about actions what performed by your users on your site call the track method. The track method tells us a name of “event” and also may include properties associated with that event.

For example this snippet is telling us that your user triggered Search event and the user is looking for 'Wristwatch':

analytics.track('Searched', {
query: 'Wristwatch'

You may track any user actions and send events which indicates metrics valuable for you business, like Signed Up, Item Searched or Added To Cart.

Keep on reading to know more about analytics.js API.

Analytics.js API

Read more about methods provided by analytics.js.

Anonymous ID

analytics.js takes care to track all visitors of your site. For visitors who are not identified in you system yet analytics.js will automatically generate an anononymousId and will pass it along with all events triggered by the user event after user is identifyed.


The identify method is how you tell EPICA that a user is recognized in your system by userId and traits.


analytics.identify([userId], [traits], [options]);


userId optional String The ID of the user in you system.
traits optional Object An object with data known about the user, like their age or name.
options optional Object An options object for analytics.js tuning. Note: If you do not have traits for the user, pass an empty object (ie, ‘{}’) before options.


The track method lets you record what actions performed by a users on your site.


analytics.track(event, [properties], [options]);


event String The name of the event you’re tracking.
properties optional Object An object with data associated with the event. If the event was 'Purchased', it might have properties like item, category and price.
options optional Object An options object for analytics.js tuning. Note: If you do not have traits for the user, pass an empty object (ie, ‘{}’) before options.

The only required argument to track in analytics.js is an event name string.

Example track call:

analytics.track('Added Extras', {
item: 'Breakfast + Вinner',
price: '20.0',


The page method lets you record page views and optional extra information about the page being viewed on your website.

By default a page call is present at the end of the analytics.js snippet. You may modify this page call options described below.

Definition:[category], [name], [properties], [options]);


category optional String The category of the page. Useful for cases like ecommerce where many pages might live under a single category. Note: if you pass only one string to page it is assumed to be name. You must include a name to send a category.
name optional String The name of the page.
properties optional Object An object with properties describing the page.
options optional Object An options object for analytics.js tuning. Note: If you do not have traits for the user, pass an empty object (ie, ‘{}’) before options.

With each page event analytics.js will include url, title, referrer and path properties by default. For example:'Special offers');

would be equal to the following but don’t require any extra work from you:'Special offers', {
title: 'Offer of the week',
url: '',
path: '/offers',
referrer: ''

You can override default value if you pass property with same key.

Reset / Logout

Calling reset will reset the anonymousId and userId (for the identified user). New events will be recorded for the new anonymous user.