Transaction

Track a transaction

POSTtracking/transaction

Transactions are a special type of event, used to track when a user has purchased something from you. The data is reported in Ecommerce Analytics and GoSquared People.

Transactions can be tracked either in the browser using the JavaScript Tracker when a user completes a purchase, or on the backend when your application processes the transaction.

If a transaction ID is specified, it will be checked for uniqueness to prevent duplicate transactions from being tracked.

By default, GoSquared calculates the total revenue and quantity amount from the items in the transaction. You may want to override this in some cases, such as when a discount was applied. This is possible by specifying revenue and quantity totals in the transaction options.

POST Body

person_id

String

The People person ID that this action is associated with.

If the identifier used is an email it should be prefixed with email: like this: email:jon@example.com

visitor_id

String

The anonymous visitor ID that this action is associated with.

timestamp

String

A valid ISO 8601 timestamp of when this transaction happened

page

Object

index

Number

The page index that this event is associated with

transaction

ObjectRequired

id

String

revenue

Number

The total revenue from this transaction, defaults to the sum of item revenues

quantity

Number

The total number of units sold, defaults to the sum of item quantities

previous_transaction_timestamp

String

ISO 8601 timestamp of when this visitor/person last completed a transaction

items

Array

name

String

The name of this item

price

NumberDefault Value: 0

The price per unit

quantity

NumberDefault Value: 1

The number of units sold

revenue

Number

The total revenue of this item. Defaults to price ✕ quantity

categories

Array

A list of categories that this item/product is in

Run in PostmanPostman is a useful developer tool for experimenting with and managing APIs that you work with

Definition

POST https://api.gosquared.com/tracking/v1/transaction

Example Request

curl -X POST -H "Content-Type: application/json" \
  "https://api.gosquared.com/tracking/v1/transaction?api_key=demo&site_token=GSN-106863-S" 

Live Responseundefined undefined

Your API Key is not authorised for this endpoint