Transaction tracking with GoSquared

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

Note: It is not possible to remove test transactions from your Ecommerce dashboard. Therefore we highly recommend creating a test project in your GoSquared account before you start sending data to your production project.

// transaction ID should be unique and must be specified.
var transactionID = 'transaction-id';

_gs('transaction', transactionID, {
  // track immediately
  track: true
}, [
  {
    name: 'Product 1',
    price: 1,
    quantity: 5
  },
  {
    name: 'Product 2',
    price: 5,
    category: 'Test Products'
  }
]);
var GoSquared = require('gosquared');
var gosquared = new GoSquared({
  site_token: 'your-project-token',
  api_key   : 'your-api-key'
});

// transaction ID should be unique and must be specified.
var transactionID = 'transaction-id';

var transaction = gosquared.createTransaction(transactionID);
transaction.addItems([
  {
    name: 'Product 1',
    price: 1,
    quantity: 5
  },
  {
    name: 'Product 2',
    price: 5,
    category: 'Test Products'
  }
]);

transaction.track(function(err, resp) {});
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
  'site_token' => 'your-project-token',
  'api_key'    => 'your-api-key'
));

// transaction ID should be unique and must be specified.
$transactionID = 'transaction-id';
$transaction = $GS->Transaction($transactionID);

$transaction->add_items(array(
  array(
    'name' => 'Product 1',
    'price' => 1,
    'quantity' => 5
  ),
  array(
    'name' => 'Product 2',
    'price' => 5,
    'category' => 'Test Products'
  )
));

$result = $transaction->track();

Track transactions for a specific person

When an identified user triggers a transaction, you can track it with their user ID to associate it with their profile. Once tracked, you can search, filter and sort your users in People CRM to find people who have made transactions.

// so long as the user has been identified, this can be exactly the same as above

// transaction ID should be unique and must be specified.
var transactionID = 'transaction-id';

_gs('transaction', transactionID, {
  // track immediately
  track: true
}, [
  {
    name: 'Product 1',
    price: 1,
    quantity: 5
  }
]);
var GoSquared = require('gosquared');
var gosquared = new GoSquared({
  site_token: 'your-project-token',
  api_key   : 'your-api-key'
});

// transaction ID should be unique and must be specified.
var transactionID = 'transaction-id';

var person = gosquared.createPerson('user-id');

var transaction = person.createTransaction(transactionID);
transaction.addItem('My Product', {
  price: 10,
  quantity: 1
});

transaction.track(function(err, resp) {});
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
  'site_token' => 'your-project-token',
  'api_key'    => 'your-api-key'
));

$person = $GS->Person('user-id');

// transaction ID should be unique and must be specified.
$transactionID = 'transaction-id';
$transaction = $person->Transaction($transactionID);

$transaction->add_item('My Product', array(
  'price' => 10,
  'quantity' => 1
));

$result = $transaction->track();

Custom transaction properties

By default, the total quantity and revenue for a transaction is calculated by summing up each individual item. This can be overridden, which can be useful if coupons have been applied or for certain specific cases. If revenue is specified for an individual item, that will be used instead of the price × quantity. If no quantity is provided, it is assumed to be 1.

// transaction ID should be unique and must be specified.
var transactionID = 'transaction-id';

_gs('transaction', transactionID, {
  track: true,
  revenue: 119.99,
  quantity: 1
}, [
  {
    name: 'Product 1',
    revenue: 119.99
  }
]);
var GoSquared = require('gosquared');
var gosquared = new GoSquared({
  site_token: 'your-project-token',
  api_key   : 'your-api-key'
});

// transaction ID should be unique and must be specified.
var transactionID = 'transaction-id';

var transaction = gosquared.createTransaction(transactionID, {
  revenue: 119.99,
  quantity: 1
});

transaction.addItem('Product 1', {
  revenue: 119.99
});

transaction.track(function(err, resp) {});
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
  'site_token' => 'your-project-token',
  'api_key'    => 'your-api-key'
));

// transaction ID should be unique and must be specified.
$transactionID = 'transaction-id';
$transaction = $GS->Transaction($transactionID, array(
  'revenue' => 119.99,
  'quantity' => 1
));

$transaction->add_item('Peoduct 1', array(
  'revenue' => 119.99
));

$result = $transaction->track();

Next Steps