Purchase Events

For the purchase event, Analytics variables are used to capture specific purchase information. The s.purchaseID variable is used to serialize (de-duplicate) the event.

The purchaseID is limited to 20 characters. The purchaseID variable serializes all events passed in the variable s.events, and overrides any serialization value for events. If purchaseID is left blank, each instance of the purchase event, even page reloads, is counted.

If a purchase event is called without a purchaseID, a unique one is automatically generated based on the s.products and s.events variables. This automatically generated purchaseID is stored locally as a cookie value within the visitor's browser, and is not sent to any report suite tables. Manually defined purchaseIDs on the other hand are sent to a back-end table within the report suite. The last five purchases made by a visitor (with or without purchaseID) are stored in the local cookie.

When a visitor makes any purchase, the following checks are made:

Specific server-side code can be used to generate the unique number (alphanumeric value) embedded in the HTML source. Usually the Order ID, or similar alphanumeric value, is used for this purpose. This value should not change if the user refreshes the page. The following is a short example (note the purchaseID code in bold):


s.products="Category;ProductName;Qty;total_price [,Category2;ProductName2;Qty;total_price]"


s.products="Footwear;Hiking Boots (1234);1;170.00"

Additional Notes

  • Be sure to use server-side code to generate the unique identifier for the event. Do not use a JavaScript randomization function to generate a number, which generates unique numbers each time the page is loaded (each instance/pageview counts).
  • The unique identifiers are applicable to all users across all sessions. Therefore, ensure the identifier is unique across users and sessions. For instance, if the Order ID repeats after 30 days, append the date of the order to make the Order ID sufficiently unique.
  • The serialization value may be alphanumeric values up to 20 characters in length. This is identical to the limitations of s.purchaseID (replace s. with s_ for G Code).
  • The s.purchaseID variable serializes all events passed in the variable s.events, and overrides any serialization value for events. Do not use Event serialization for any events if the s.purchaseID variable is used on the current page (replace s. with s_ for G Code).