Tracking
Table of Contents
Revenue tracking
When a user is making an analysis, we recommend products to her/him. To track revenue resulting from these recommendations, each purchase must be checked if it contains a product that was recommended by the analysis.
Whenever a user finishes an analysis and in addition whenever a user opens the result page, we store the recommended products in the local storage of the user's browser (see Local Storage for more details). This information can be used by you to evaluate if a purchase was influenced by a recommendation from Stella by comparing the shopping cart items with the recommended products in the local storage.
You can use this information to build up your own analytics and track the success of our recommendations or push the information to your own platform and we will display the data in our dashboard to the client.
Push purchase information to our platform
Having the information about the purchases, we can evaluate the success of our recommendations and provide our clients with valuable insights on our dashboard.
POST all purchases made in the shop to our API endpoint https://track.askstella.ai/v1/purchase/createOrder with the following example JSON payload:
{
"company_id": "1234567890", // Your company ID in our platform
"created_at": "2024-02-28T15:08:25-05:00", // ISO 8601 formatted date when the order was placed
"currency": "EUR",
"total_price": 28.99,
"total_tax": 0,
"total_shipping_price": 3.99,
"total_discounts": 0,
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", // Optional: Information about the browser of the user
"had_chat": true, // Optional: true if the user had a chat with Stella within 3 days before the purchase, false if the chat was older and leave out this attribute if the user did not have any chat before the purchase
"line_items": [
// The ordered items
{
"name": "Dramatic Length Mascara - Brown", // Full name of the purchased product (product name + variant name)
"product_id": 7080352251969, // int or string (product id in your shop)
"variant_id": 40814619394113, // if your system does not use variants, set this to the product_id as well
"price": 24.0,
"quantity": 1,
"total_discount": 0.0, // Optional: Discount given for this item
// the following fields must be set if this product was recommended by a Stella analysis (otherwise leave them out)
"stella_source": "analyse_finished", // one of our internal source identifiers in our local storage - this is only for advanced tracking, you can also always set this to "analyse_finished" for simplicity
"analysis_id": "1234ASDF", // analysis_id where it was recommended
"funnel": "funnelDomain" // funnel identifier where it was recommended
}
]
}Using the frontend event instead of direct API calls
If you are using the Stella shop components library, you can also send purchase information via a browser event instead of calling the tracking endpoint directly. The library listens for the stellaPurchaseCompleted event on window and will build and send the tracking payload for you.
The event payload is a simplified order object without tracking-specific fields:
window.dispatchEvent(new CustomEvent("stellaPurchaseCompleted", {
detail: {
currency: "EUR", // ISO 4217 currency code
total_price: 27.99, // float
total_tax: 0, // float
total_shipping_price: 3.99, // float (optional)
total_discounts: 0, // float
// Line items in the order
line_items: [
{
name: "Dramatic Length Mascara - Brown",
product_id: "7080352251969", // int or string (product id in your shop)
variant_id: "40814619394113", // if your system does not use variants, set this to the product_id as well
price: 24.0, // float
quantity: 1, // int
total_discount: 0 // float (optional)
}
]
}
}));Tracking of analysis sources
To analyse from where users came to start an analysis, we store the sourceparameter of the query string of the iframe's URL with the analysis. We attach this parameter automatically for sources out of our own tools, e.g. the chat from StelleAssist will open the analysis with https://<your identifier>.askstella.ai/?source=chat. If you want to track sources from your website, you can add the source parameter to the URL of the iframe yourself with any parameter you like.
If you need even more control, we are also storing the full query string of the iframe's URL in the query_string property of the analysis, which is available to you in the Webhook, the CRM sync and data exports.
Tracking using Google Tag Manager
If you are using Google Tag Manager, we can add your Google Tag Manager ID to our analysis funnels. This will allow us to track the analysis sources in your own analytics tool. Add the ID in your company settings in the dashboard.
To disable the GTM tracking, e.g. if the user consent is missing, you can dynamically add the disable_tracking=true query parameter to the URL of the iframe.