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.

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}"
}
'