You are here

function ga_push_add_ecommerce in GA Push 8

Same name and namespace in other branches
  1. 7 ga_push.module \ga_push_add_ecommerce()

Push a GA ecommerce.

Ecommerce tracking allows you to measure the number of transactions and revenue that your website generates. On a typical ecommerce site, once a user clicks the "purchase" button in the browser, the user's purchase information is sent to the web server, which carries out the transaction. If successful, the server redirects the user to a "Thank You" or receipt page with transaction details and a receipt of the purchase.

@note Important! The Ecommerce plug-in should not be used alongside the Enhanced Ecommerce (ec.js) plug-in.

Example:

ga_push_add_ecommerce(array(
  'trans' => array(
    'id' => '1234',
    'affiliation' => 'Acme Clothing',
    'revenue' => '11.99',
    'tax' => '1.29',
    'shipping' => '5',
    'currency' => 'EUR',
    'city' => 'San Jose',
    // Classic Analytics only.
    'region' => 'California',
    // Classic Analytics only.
    'country' => 'USA',
  ),
  'items' => array(
    array(
      'id' => '1234',
      'sku' => 'DD44',
      'name' => 'T-Shirt',
      'category' => 'Green Medium',
      'price' => '11.99',
      'quantity' => '1',
      'currency' => 'EUR',
    ),
  ),
));

Parameters

array $push: An associative array containing:

  • trans: array Transaction data. An associative array containing:

    • id: The transaction ID. (e.g. 1234).
    • affiliation: (optional) The store or affiliation from which this transaction occurred (e.g. Acme Clothing).
    • revenue: Specifies the total revenue or grand total associated with the transaction (e.g. 11.99). This value may include shipping, tax costs, or other adjustments to total revenue that you want to include as part of your revenue calculations.
    • tax: (optional) Specifies the total tax of the transaction. (e.g. 1.29).
    • shipping: (optional) Specifies the total shipping cost of the transaction. (e.g. 5).
    • city: (optional) city. Only compatible with Classic Analytics.
    • region: (optional) state or province. Only compatible with Classic Analytics.
    • country: (optional) country. Only compatible with Classic Analytics.
    • currency: currency (ISO 4217).
  • items: array Items data. A multiple associative array containing on each row:

    • id: The transaction ID. This ID is what links items to the transactions to which they belong. (e.g. 1234)
    • name: The item name. (e.g. Fluffy Pink Bunnies).
    • sku: (optional) Specifies the SKU or item code. (e.g. SKU47).
    • category: (optional) The category to which the item belongs (e.g. Party Toys).
    • price: (optional) The individual, unit, price for each item. (e.g. 11.99).
    • quantity: (optional) The number of units purchased in the transaction. If a non-integer value is passed into this field (e.g. 1.5), it will be rounded to the closest integer value.
    • currency: currency (ISO 4217)

string $method_key: Method key.

array $options: Extra options.

See also

https://developers.google.com/analytics/devguides/collection/analyticsjs...

https://developers.google.com/analytics/devguides/collection/gajs/gaTrac...

ga_push_add()

File

./ga_push.module, line 366
Drupal Module: GA Push.

Code

function ga_push_add_ecommerce(array $push, $method_key = NULL, array $options = []) {
  ga_push_add($push, GA_PUSH_TYPE_ECOMMERCE, $method_key, $options);
}