PriceShape provides an open API to integrate sales data from your shop, allowing you to track conversion rates, set up price strategies based on product performance, and create intelligent product groupings based on sales data.
The data can be sent to PriceShape via the Sales data API or with PriceShape's Sales data script.
Notes on Implementation
The script is designed for use in the website’s source code.
If you choose to use a tag manager, you must adapt the script to your setup and ensure triggers fire at the correct moments (page views, add-to-cart, purchase).
Overview of data events
For each product, you can track and send these events:
Page Views: The total number of product-specific pages viewed.
Products Added to Cart: The number of times a product is added to the shopping cart.
Products Sold: The total quantity of a specific product sold.
Unique Product Sales: The number of unique transactions involving a specific product.
Client-side script
The Script works by events or triggers, which means that when a customer navigates or interferes with a certain part of the website, the script needs to be triggered accordingly.
Timestamp
All events can include an optional timestamp field.
Format: ISO-8601 in UTC, e.g.
"2023-04-10T02:12:00Z"
Head Script
Place the following in the <head> of your page template. It should be available on all pages (or at a minimum on pages where you track events) and above the event scripts in the source code.
You can find your unique script in "Account settings" -> "Integrations".
<script type="text/javascript"> (function (window) { function sendEvent(body) { if (!window.navigator || !window.navigator.sendBeacon) { console.log("This browser does not support sendBeacon"); return false;
} window.navigator.sendBeacon( "https://public.app.priceshape.io/api/2022-08/sales-data?app_id=####", JSON.stringify(body) );
} window.PRICESHAPE = { trackPage: function (upi) { sendEvent([
{ pageViews: 1, upi
}
]);
}, itemSold: function (upi, quantity = 1) { sendEvent([
{ itemsSold: quantity, uniqueSales: 1, upi
}
]);
}, itemsSold: function (data) { sendEvent(data);
}, itemAddedToCart: function (upi) { sendEvent([
{ itemAddedToCart: 1, upi
}
]);
},
};
})(window); </script>Event Scripts
Implement these at the bottom of the <body> on the relevant pages to track page events.
Product Page Views
Trigger condition: When a customer navigates to a product-specific URL.
If you work with variants, you might need to tweak the logic to account for variants by either:
Trigger a single view for the first variant clicked.
Trigger a view for each variant the customer clicks.
// Track a page view, by UPI
<script
type="text/javascript"> window.PRICESHAPE.trackPage(upi)
</script>
Items Sold and Unique Sales:
Trigger condition: Once a customer purchases an item.
Items sold and unique sales should trigger on the “Thank you for your order page" or when the transaction is completed.
// Track items sold, by UPI
<script
type="text/javascript"> window.PRICESHAPE.itemSold(upi, quantity) </script>
// if multiple products at once
// UPI is a string
window.PRICESHAPE.itemsSold([
{ upi: '001234567', itemsSold: 2, uniqueSales: 1},
{ upi: '000567789', itemsSold: 1, uniqueSales: 1},
])
Added to Cart:
Triggers condition: Once a customer adds an item to the cart.
// Track added to cart, by UPI
<script
type="text/javascript"> window.PRICESHAPE.itemAddedToCart(upi)
</script>
Data Format
Data should be submitted via a POST request to:
https://public.app.priceshape.io/api/2022-08/sales-data?app_id=xxxxxxxx
You can find your unique script in "Account settings" -> "Integrations".
Naming conventions and format
All data must be in JSON format and follow these naming conventions:
pageViews
upi (See PriceShape UPI here)
itemsSold
uniqueSales
timestamp (ISO-8601 UTC)
Syntax Example
Data requests should be posted as an array of objects. Example:
[{"pageViews": 1, "upi": "5705145043275"},{ "upi": "5705145043275", "itemsSold": 2, "uniqueSales": 1},{"upi": "5705145043275", "itemAddedToCart": 2}]For single events:
[{"upi": "5705145043275", "itemAddedToCart": 2}]Note: Ensure that strings and numbers are appropriately distinguished.
