Attraqt
Search…
📌
Quickstart guide
Follow the Quick start guide to quickly try out and implement Attraqt's tracking system

Why do you need to implement Attraqt's tracking system?

To benefit from all Attraqt's platforms capabilities, it is important to collect and unify the right data from every touch point of the Shopper journey. Through Attraqt's platforms, you will be able to learn more about the behavior of your users, how changes you make to your website affect their behavior, and how to provide the best shopping experience. To begin the process you need to start sending activities.

Sending your first activity

Before you begin you should have a tracker key provided to you by Attraqt. Once you do, you can continue with this guide. Your tracker key is a unique UUID used by our service to identify the environment you're sending events to, so they arrive at the right place. You would usually have a tracker key for every different version of your website (for different markets).
An activity is an object which represents an action(such as a view) made by an anonymous visitor or an identified visitor on a target(such as a product).
There multiple ways you can send activities depending on your use case. You can read more on the different implementations below.
Let's send your first activity. As part of this quickstart guide we will cover use of the JavaScript SDK and the REST API.
To install the SDK through NPM, add the xo-js client to your dependencies, or add the script from the CDN.
NPM
CDN
1
npm install --save @attraqt/xo-js
Copied!
1
<script type="text/javascript">
2
!function(att,raq,t){
3
var version = "1";
4
var supportOldBrowsers = false;
5
att[raq]=att[raq]||[];var n=["init","send","setUser","addUserIdentity","setUserIdentities","addUserSegment","setUserSegments","addUserTrait","setUserTraits","clearUser"];if(!att.xo){att.xo={activity:{},init:function(e){att[raq].push(["init",e.activity])}};for(var r=0;r<n.length;r++)att.xo.activity[n[r]]=function(e){return function(i,r,s){att[raq].push([n[e],i,r,s])}}(r)}var s=document.createElement("script");s.type="text/javascript",s.async=!0,s.src=t+version+".min.js",(att.document.documentMode||supportOldBrowsers)&&(s.src=t+version+".compat.min.js");var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(s,a)
6
}(window,"_attraqt","https://cdn.attraqt.io/xo.all-");
7
</script>
Copied!
Important! The xo-js library is used for both XO and FHR. Even though the code snippets mention xo **in the variables, they work just as well for FHR.**
Our package is written in TypeScript and natively supports it.
Assuming you have your tracker key ready, if we want to register a view action on a product with the id 123, we need to execute the following JavaScript snippet using the SDK, or make the following API Call:
JavaScript SDK
API Call
1
// First, import the library
2
const xo = require('@attraqt/xo-js');
3
4
// Next, you have to initialize the SDK with your tracker key
5
xo.init({activity: {trackerKey: '30cbb5fc-375f-4cf2-8efd-ed86d909718e'}});
6
7
const myActivity = {
8
"action": "view",
9
"target": {
10
"product": "123"
11
},
12
"user": {
13
"identities": {
14
"sessionId": "2ee80450-28ed-11eb-adc1-0242ac120002"
15
}
16
}
17
};
18
19
// Then, use the send() method of the SDK
20
xo.activity.send(myActivity);
Copied!
1
# the uuid at the end of the endpoint should be your tracker key
2
curl "https://collect-eu.attraqt.io/30cbb5fc-375f-4cf2-8efd-ed86d909718e"
3
-X POST
4
-H "Content-Type: application/json"
5
-d '{
6
"action": "view",
7
"target": {
8
"product": "123"
9
},
10
"user": {
11
"identities": {
12
"sessionId": "2ee80450-28ed-11eb-adc1-0242ac120002"
13
}
14
}
15
}'
Copied!
By using the API directly, you have to generate a unique session ID for each users

The activity

The action field represents the action the user performed, or in this case, a view on a product. The target object covers the details of the target of the action(view), or in this case a product with id 123. The user object contains the identities, or in this case, the session id.
This simplified activity contains very little information. As a general rule, the more information you can provide, the better results you'll get out of the analytics and all the features Attraqt offers. You can read more on the activity object below.

Identities

In order to be able to perform analytics on the actions of Shoppers, you need to be able to distinguish users of all the events you send. This way, you would be able to link different actions a Shopper makes (clicks, purchases etc.) to better understand their behavior, and improve their shopping experience. This is where identities management comes in.
At least one identity - session id - is needed to be able to send events to our tracking system. More information on managing identities available below.
Response
If your integration is correctly configured, you should receive a successful 201 response! In case there is something wrong with your tracker key or the SDK/endpoint, you will receive an error message and you should contact Attraqt for further assistance.

Next steps

If you got the example from this quickstart guide working, you can move onto the next sections of this documentation.
Last modified 21d ago