Skip to main content
Custom Sales data script

Add and adapt a script to your site that sends sales data to you account

Steffan H. Mathiasen avatar
Written by Steffan H. Mathiasen
Updated over a week ago

Overview

PriceShape has an open API to integrate data from your shop into PriceShape. By sending data like page views and the number of sales, PriceShape can track your conversion rates and enable you to set up price strategies based on how well your products are doing.

The data can be sent to PriceShape via the Sales data API or with PriceShape's Sales data script.

The following events can be sent to PriceShape per product:

  • Page viewed: The amount of pageviews

  • Product added to cart: The number of times a product has been added to the cart

  • Product sold: The amount of product sold

  • Unique product sales: The number of times a product has been sold

Client-side script

In the <head> tag of your page template. 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>

Then at the bottom of the <body> element for all pages to track page views, you will need to add the following.

Product Pageviews:

// Track a page view, by UPI
<script
type="text/javascript"> window.PRICESHAPE.trackPage(upi)
</script>


The scripts for items sold and added to the cart needs to be called every time a customer adds a product to the cart and when the items have been sold.


Items sold and Unique sales:

// 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:

// Track added to cart, by UPI
<script
type="text/javascript"> window.PRICESHAPE.itemAddedToCart(upi)
</script>

Did this answer your question?