Skip to content

Enhanced Ecommerce Tutorial #9

@diwant

Description

@diwant

Hello,

Thank you for this library, it may be exactly what I need although I need some help hence this issue.

I would like to use this library to implement the following use case, and I believe it's possible from reading other issues posted here but I do not understand what the calls should look like.

A shopper checks out via a few steps on my site and then is sent to PayPal to complete payment. Before sending to PayPal I lift the GA Client Id (GACID) from the cookie and send that to PayPal via the custom data parameter available in their button creation code. After payment, I also listen for an IPN which determines that payment has been completed for the order.

Once I get the IPN, I want my server code to use the universal-analytics-python library and send an Enhanced Ecommerce transaction event to GA for that client. As mentioned above, I know their GACID. I also will have all the details for the order the IPN refers to.

What should my code look like on my server so, using this library, I can send something like the below to GA?

ga('ec:addProduct', {               // Provide product details in an productFieldObject.
  'id': 'P12345',                   // Product ID (string).
  'name': 'Android Warhol T-Shirt', // Product name (string).
  'category': 'Apparel',            // Product category (string).
  'brand': 'Google',                // Product brand (string).
  'variant': 'black',               // Product variant (string).
  'price': '29.20',                 // Product price (currency).
  'coupon': 'APPARELSALE',          // Product coupon (string).
  'quantity': 1                     // Product quantity (number).
});

ga('ec:setAction', 'purchase', {          // Transaction details are provided in an actionFieldObject.
  'id': 'T12345',                         // (Required) Transaction id (string).
  'affiliation': 'Google Store - Online', // Affiliation (string).
  'revenue': '37.39',                     // Revenue (currency).
  'tax': '2.85',                          // Tax (currency).
  'shipping': '5.34',                     // Shipping (currency).
  'coupon': 'SUMMER2013'                  // Transaction coupon (string).
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions