Introduction

The Analytics API allows you to push events to Tweakwise that are related to actions visitors and customers undertook on your storefront. This may include actions such as viewing a product's detail page or making a purchase. This data can subsequently be used to personalize listing pages.

Instead of implementing the API, most implementations are better off using our Personalization Pixel. Using this JavaScript plugin is easier to use than implementing the Analytics API yourself because it takes some of the needed work out of your hands. However, if you have a need to implement the Analytics API in another platform or server-side, then you’re in the right place.

Authentication

Just as with the frontend API, does authorization take place solely based on the instance key. The Analytics API expects you to send the instance key as a header named Instance-Key. You can find your instance key in the app under Connectivity → Endpoints.

Profile key

Customer identification is done through the profile key. You need to identify your customers using a unique identifier. You can determine the profile key yourself; think of options such as customer id, visitor id, IP hash, etc.. Without identification, events are added to anonymous customers.

While non-authenticated users are typically tracked using a storage-based ID, once a user logs in, switching to an account-specific ID is recommended to make sure cross-device tracking works correctly.

🚧

Be careful

The use of personal information such as email addresses, phone numbers, or other personal information as profile keys is not permitted in order to comply with GDPR guidelines. Therefore, only use anonymized data such as ID numbers or hashed values. By following the GDPR guidelines, you meet the requirements for the protection of users and data.

🚧

Good to know

The profile key has a maximum length of 128 characters.

Endpoints

The Analytics API is relatively small and knows only a few endpoints related to tracking specific actions. To use any of the endpoints, it's necessary to include a profile key. This profile key serves as a unique identifier for an individual visitor or customer on your website.

NameEndpointDescription
Track page view/api/pageviewProvide Tweakwise with information about which product pages your visitors have viewed.
Track purchase/api/purchaseGive Tweakwise data about which products a customer has bought.
Track search/api/searchSupply Tweakwise with information about what visitors searched for.

Example request

With that out of the way, we can try to make a request to the analytics API already. In this example we're tracking a visitor (identified by the profile key) who viewed a specific product (identified by article number).

curl --request POST \
     --url https://navigator-analytics.tweakwise.com/api/pageview \
     --header 'Instance-Key: {instanceKey}' \
     --header 'Content-Type: text/json' \
     --data '
{
  "ProductKey": "{articleNumber}",
  "ProfileKey": "{profileKey}"
}
'

Profile retention

The retention of profiles is determined by the maximum number of profiles allowed in your account. For instance, if your account allows up to 100,000 profiles, the addition of a new profile will trigger the deletion of the longest inactive profile once this limit is reached.