Analytics

How to add analytics script

To include Tipser Script on your site, use the following script element. It exposes a global tipserAnalytics variable that can be used to initialize and configure the script.

<script src="https://cdn.tipser.com/tipser-script/v4/tipser-analytics.min.js"></script>

Initialization

To initialise Tipser Script, run the following line of JS code:

tipserAnalytics.initialize("YOUR_POS_ID", {
	env: 'prod'
});

Make sure that the YOUR_POS_ID is replaced with the actual id corresponding to your account. The env option is optional, and it is set to prod by default.

Dispatching impression events

Currently, the script supports 3 types of impression events:

  • product tile impression
  • product details impression
  • cart impression

Those events are dispatched automatically when corresponding attributes are found in the DOM tree. To dispatch product tile impression you need to add "data-tipser-analytics-product-tile"="PRODUCT_ID to product tile container (please remember to replace PRODUCT_ID with real an id of product), for example:

	<div data-tipser-analytics-product-tile="60479d1fdb3410ad13e27fab">
		<!--Product tile code -->
	</div>

In case of product details impression the attribute is different (data-tipser-analytics-product-details="60479d1fdb3410ad13e27fab"), but the usage is similar:

	<div data-tipser-analytics-product-details="60479d1fdb3410ad13e27fab">
		<!--Product page code -->
	</div>

Finally, in case of cart impression we don't need any id. The attribute is data-tipser-analytics-cart="":

	<div data-tipser-analytics-cart="">
		<!--Cart code -->
	</div>

Dispatching action events

Actions events have to be dispatched manually. Currently, the script supports 3 types of action events:

  • add to cart
  • remove from cart
  • product click

You should store somewhere the object that is returned by initialize function and then you can use it in following way:

window.analytics = tipserAnalytics.initialize({
	env: 'prod',
	posId: "YOUR_POS_ID"
});

then the usage of action events can look like:

function addToCart() {
	window.analytics.dispatchAddToCart('60479d1fdb3410ad13e27fab')
}

function removeFromCart() {
	window.analytics.dispatchRemoveFromCart('60479d1fdb3410ad13e27fab')
}

function productTileClick() {
	window.analytics.dispatchProductTileClick('60479d1fdb3410ad13e27fab')
}