e-comm: Order Placed

"Order Placed" is the ultimate goal of the typical e-commerce conversion funnel. It is recognized in Adobe Analytics by the purchase event with the inclusion of a purchaseID, and a product string containing productID, quantity, and cost for each item purchased. These items are used within Adobe Analytics to populate the "Orders", "Units", and "Revenue" metrics.

The Orders metric is incremented whenever Adobe Analytics is sent a purchase event with a purchaseID that has never-before been seen within the report suite. If a purchase event is sent with a previously seen purchaseID (even one from years ago), the beacon will be marked as a duplicate causing no population of "Orders", "Units", and "Revenue" metrics.

The Adobe Analytics Orders metric is incremented whenever Adobe Analytics is sent a purchase event with a purchaseID that has never-before been seen within the report suite. If a purchase event is sent with a previously seen purchaseID (even one from years ago), the beacon will be marked as a duplicate causing no population of "Orders", "Units", and "Revenue" metrics.

Also worth noting is the fact that only the first 20 characters of the purchaseID are evaluated for uniqueness. (Still true as of Feb 2019...)

In our example, we will set the purchase event (serialized in the Adobe Analytics based on purchaseID). We'll include the Adobe Analytics basics - Category, productID, quantity, and cost.

We'll also include few extra pieces of data in order to demonstrate the power of the extension.

  1. A non-product currency custom event to record the sales tax (event50)

  2. A traffic variable to record the purchaseID (prop50)

  3. Capture of the purchaser's State and Zip (s.state, s.zip)

  4. Set s.transactionID to support upload of offline data against the transaction (Returns, Cost of Goods, etc)

  5. Use a product syntax merchandising eVar (eVar20) to capture SKU

  6. Use a product specific numeric event to count backordered items (event22)

We'll also include a second AA Product String Action to record information about the payment amounts and methods.

  1. Payment Amount is captured using a product specific custom currency event (event33)

  2. Payment Method is captured using a product syntax merchandising eVar (eVar33)

  3. We'll access a different product collect for this action (transaction.payment)

  4. We'll use transaction.payment[n].paymentID to set our product ID in the product string.

Overview

We'll start with this event being pushed to our data layer by the application. Notice that our product array is now represented by the product collection, transaction.item[n]. Also notice that we have a second product collection, transaction.payment[n]. We'll use two AA Product String Builder Actions (one for each collection) in this example.

window.appEventData = window.appEventData || [];
window.appEventData.push({
  "event": "Order Placed",
  "transaction": {
    "transactionID": "OSMA0876565433",
    "total": {
      "currency": "USD",
      "salesTax": "12.98"
    },
    "profile": {
      "address": {
        "stateProvince": "WI",
        "postalCode": "53533"
      }
    },
    // Collection of Payment Objects
    "payment": [{
        "paymentMethod": "Gift Card",
        "paymentID": "payment_1",
        "paymentAmount": "100.00"
      },
      {
        "paymentMethod": "Amex",
        "paymentID": "payment_2",
        "paymentAmount": "160.28"
      }
    ],
    // Collection of Item Objects
    "item": [{
        "quantity": 3,
        "productInfo": {
          "sku": "HC30ABJ786-XL-GRN",
          "productID": "HC30ABJ786",
          "isBackOrdered": false
        },
        "price": {
          "sellingPrice": "55.00"
        }
      },
      {
        "quantity": 1,
        "productInfo": {
          "sku": "WB2211-A",
          "productID": "WB2211",
          "isBackOrdered": true
        },
        "price": {
          "sellingPrice": "82.30"
        }
      }
    ]
  }
});

We will create a rule in Launch that will build and send a beacon to record the event Adobe Analytics. The steps that we will detail are:

  1. Set up Data Elements for transactionID, zip, state, currency, and salesTax.

  2. Create a rule triggered by the Data Layer Manager : Data Layer Push for "Order Placed"

  3. Add an Adobe Analytics Action to set purchase, and event50 for salesTax collection in the events string. Also set prop50, state, zip, transactionID, currency, and purchaseID.

  4. Add one AA Product String Builder action to record traditional products setting the product string Category, ProductID, Quantity, Cost, Merchandising eVars, and Custom Events fields.

  5. Add a second AA Product String Builder action to record information about payments.

  6. Add an Adobe Analytics Action to Send a Beacon.

  7. Test this event in the browser console.

After all is said and done, our rule will look like this:

Note that the AA Product String Builder can handle layered actions on the same product string. The layering is coordinated by using Category (the first parameter of the product string). We set category to "product" for traditional products and to "payment" for the payment entries.

The beacon that we will produce will look like this:

Step 1 - Set up Data Elements

In addition to our context aware data element which returns the data layer object, we will need to set up data elements in order to access five values which will be included in our Adobe Analytics beacon. Since the setup is essentially the same process for all five, we'll detail only one here. After all five are done, we'll have this view in the Data Elements tab.

For our example, let's set up transaction.profile.address.postalCode

Create a new Data Element to reference the Data Layer Push's event object.

  1. Enter transaction.profile.address.postalCode in the Name field.

  2. Choose Data Layer Manager as the Extension.

  3. Choose Context Aware for Data Element Type.

  4. Enter transaction.profile.address.postalCode in the Data Layer Path field.

  5. Click Save.

Repeat this process for the remaining four:

  • transaction.profile.address.stateProvince

  • transaction.total.currency

  • transaction.total.salesTax

  • transaction.transactionID

Step 2 - Event Trigger: Data Layer Push - Order Placed

The event that triggers our rule is provided by the Data Layer Manager extension. Select from the options or type in "Order Placed" for Event Name. We get this value from the event key in the data layer push code shown above.

Step 3 - Adobe Analytics - Set Vars

Add an Adobe Analytics Action to the rule setting

  • prop50 to the transaction.transactionID data element

  • purchase in the events section

  • event50 in the events section with a value from the transaction.total.salesTax data element

  • State using the transaction.profile.address.stateProvince data element

  • Zip using the transaction.profile.address.postalCode data element

  • Transaction ID using the transaction.transactionID data element

In order to set currency and purchaseID we need to click the </> Open Editor button and add a bit of javascript.

s.currency = _satellite.getVar("transaction.total.currency");
s.purchaseID = _satellite.getVar("transaction.transactionID");

//Since we are using an s.tl() call we need to update s.linkTrackVars
s.linkTrackVars = appendList(s.linkTrackVars, "currency");
s.linkTrackVars = appendList(s.linkTrackVars, "purchaseID");

function appendList(listString, stringtoAdd){
  var listArray=[];
  if (listString) {
    listArray = listString.split(",");
  }
  listArray.push(stringtoAdd);
  return listArray.join(",");
}

Step 4 - AA Product String Builder - Set Variables for Products

This action works in concert with the Adobe Analytics Set Variables action. Note that we set purchase and event50 (and a handful of other variables) using the Adobe Analytics extension, but we are setting the product specific custom events in the AA Product String Builder extension.

  1. Root Data Object - Here we are using %Data Layer Root% which is a Context Aware Data Element provided by the Data Layer Manager. It returns a JSON object that represents the current state of the data layer (including events that may have been pushed prior).

  2. Product Collection Path - This tells the Product String Builder how to find the product collection. A product Collection is an Array of objects containing product information. In this case, the product collection path is transaction.item.

  3. Category - This populates the first part of the product string. Setting it to "product" is one way of telling in Adobe Analytics reporting that this is a "real product".

  4. Product ID - This is the unique identifier of the product that is being viewed. In this example, the path within the product collection to the Product ID is transaction.item[n].productInfo.productID .

  5. Quantity - This value is set only when we are recording a purchase event. It populates the Units metric in Adobe Analytics.

  6. Unit Price - This value should only be set when recording a purchase event. It populates the revenue metric in Adobe Analytics. Note that we are setting this to the unit price of the item. The AA Product String Builder will automatically calculate the extended cost (using quantity * unit price).

  7. Product String Custom Events - For each product specific custom event, we select the event number that will be set and the path within the product collection to its value. In this example there is only one custom event (event22 populated from transaction.item[n].productInfo.isBackordered). Note that we've selected the "Boolean Flag" checkbox for this event. With this setting, we expect the data layer attribute to be a boolean value (true or false). If true, the custom event will be set to 1. If false it will be set to 0.

  8. Product String Merchandising Evars - For each product syntax merchandising eVar, we must select the eVar number and the path within the product collection to its value. As noted for custom events, multiple merchandising eVars may also be set here. The AA Product String Extension takes care of all of the formatting. Here, we are setting eVar20 to the value of transaction.item[n].productInfo.sku.

Step 5 - AA Product String Builder - Set Variables for Payments

This action is very similar to the one in Step 4 above. The primary difference is that we are operating from a different product collection, transaction.payment[n]. The other difference is that we do not set Quantity or Unit Price.

  1. Root Data Object - Same as above.

  2. Product Collection Path - This tells the Product String Builder how to find the product collection. A product Collection is an Array of objects containing product information. In this case, the product collection path is transaction.payment.

  3. Category - This populates the first part of the product string. Setting it to "payment" is one way of telling in Adobe Analytics reporting that this is a different use of the product variable.

  4. Product ID - This is the unique identifier of the product that is being viewed. In this example, the path within the product collection to the Product ID is transaction.payment[n].paymentID .

  5. Product String Custom Events - In this example we are capturing the paymentAmount in event33.

  6. Product String Merchandising Evars - In this example we are setting eVar33 to the paymentMethod.

Step 6 - Adobe Analytics - Send Beacon

This step is pretty basic, but included here to be complete. We are using a Custom Link beacon here and setting the Link Name to "Order Placed". There is nothing special about this; use any value that you like.

Step 7 - Testing in the console

Finally, we'll do an end-to-end test of this rule by building our changes into the development environment, and manually pushing the event object onto our data layer. In the image below, the Adobe Analytics Server call info is provided by a free Chrome plug-in called Debugger for Adobe Analytics.

Last updated