AudienceView Connect

Use Case Four (GTM) - Implementing Conversion Tags for Specific Products

Hopefully visitors to your website don’t restrict themselves to buying one product at a time. When they do purchase multiple products on a single order, let’s say two tickets for two different shows, you need to decide how you are going to report that data for conversion tracking.

In Use Case Two – Implementing a Basic Conversion Tag we implemented a conversion tag that sent the whole value of the order as the conversion. You may want to fire the tag only when a specific product is on the order and only send the quantity and value of the product (rather than the total order value) to the marketing agency owning the advertising campaign.
 

Implementation

The video below demonstrates the steps required to complete this use case. Please watch the video in conjunction with the documentation.



For this type of tag we need to get a little bit more complex. We need to fire the tag only when our product exists on the completed order and ask the dataLayer for only the quantity and value of that product. We could write a bunch of JavaScript code to interrogate the dataLayer for this information. Fortunately we’ve made this a little bit easier with what we call ‘utility functions’ which we can access using variables.
top

Required Variables

The first thing we need to do is create a reference to the order with a variable. We will use this reference within other variables. This is a one-time process; you won’t need to do this every time you want to create conversion tags based on products on the order.
  1. Choose the option to create a new variable.
  2. Give the variable a name of avOrder.
  3. Set the 'Variable Type' to Data Layer Variable.
  4. Set the 'Data Layer Variable Name' to av.order.
  5. Set the 'Data Layer Version' to Version 2.
  6. Save the variable.
Now we need to create some variables that query the dataLayer. We are going to ask the dataLayer to tell us whether a particular product of a particular type (e.g. is it an admission or a bundle) exists on the completed order and what the total value of that product was and the quantity of that product on the order. Those three individual questions will be contained within three individual variables.

We are going to create Custom JavaScript variables for these three questions which means that we are going to write a little bit of code to request the data. Don’t be too alarmed by this if you are not familiar with writing computer code. If you copy the code below (and make the changes needed for your products) you will be able to create these variables without understanding exactly what the code is doing.
top

Does the Product Exist on the Order?

The first Custom JavaScript variable we will create will be the variable that asks whether the product exists on the order. This variable will respond with true if the product exists on the order and false if it does not.
For this use case the product we are interested in is any performance of ‘Wizard Of Oz’.
  1. Choose the option to create a new variable.
  2. Give the variable a name of wizardExists.
  3. Set the 'Variable Type' to Custom JavaScript.
    This will create a text entry box.
  4. Paste the code in below as is into the text entry box and save the variable
function () {
return {{avOrder}}.productExists(‘admission’,’Wizard of Oz’);
}

Before we proceed, let’s take a quick look at what that bit of code is doing. Ignore the function part; just know that you need to have the code contained within the function. Notice how we are referencing the avOrder variable that we created as the first step in this use case. You can reference variables within custom JavaScript tags by surrounding them with double curly braces ({{ }}). We are referring to the completed order object and then referring to the ‘productExists’ utility function. A function is just a piece of code that is going to do some work for us. This particular function is going to scour through the order and if it finds our product it will return true. If there is no match the function will return false. This particular function wants us to provide two pieces of information to help it find the product: the product type and the product name.

If you want to understand the various product types and methods that you can use to refer to the product name, much more detail on the utility functions is contained within the Technical Appendix . At this point understand that we have told the function to look at all of the admission products on the order and return true if any of them have the performance code, performance short description or performance description of exactly ‘Wizard of Oz’. By exactly we mean that these fields contain no other characters and the cases match (e.g. ‘Wizard of Oz’ not ‘Wizard of Oz – The Musical’ and ‘Wizard’ not ‘wizard’).
We don’t have to be quite so exact using these utility functions. We can also provide a pattern to search for.
 
function () {
return {{avOrder}}.productExists(‘admission’,/wizard/i);
}


In this example /wizard/i means return true if the performance code, performance short description or performance description contain the word ‘wizard’ at any point and the ‘/i’ means we don’t care about the case. This is called pattern matching and these utility functions support what are known as regular expressions. You can use Google to find out more about regular expressions.
top

What is the Value of My Product on the Order?

  1. Choose the option to create a new variable.
  2. Give the variable a name of wizardValue.
  3. Set the 'Variable Type' to Custom JavaScript.
    This will create a text entry box.
  4. Enter the code below into the text entry box.
  5. Save the variable.
 
function () {
return {{avOrder}}.productValue(‘admission’,’Wizard of Oz’);
}

You’ll notice that this variable is almost identical; the only change is that we are now referring to the ‘productValue’ utility function. We are passing exactly the same request: find admissions on the completed order where the performance code, performance short description or performance description is exactly ‘Wizard of Oz’. This function will return the value of those admissions to us.
top

What is the Quantity of My Product on the Order?

  1. Choose the option to create a new variable.
  2. Give the variable a name of wizardCount.
  3. Set the 'Variable Type' to Custom JavaScript.
    This will create a text entry box.
  4. Paste the code in below as is into the text entry box and save the variable
function () {
return {{avOrder}}.productCount(‘admission’,’Wizard of Oz’);
}

The only change is the reference to productCount. This will give us the number of admissions instead of the value of those admissions.

Each type of product will have a different way of providing a count. For example, we provide the count of the bundles not the number of admissions within the bundles. For more information, refer to the Technical Appendix.

The Order Number

If you haven’t done so already, create a variable to ask for the order number of the completed order:
  1. Choose the option to create a new variable.
  2. Give the variable a name.
  3. Set the 'Variable Type' to Data Layer Variable.
  4. Set the 'Data Layer Variable Name' to av.order.order_number.
  5. Set the 'Data Layer Version' to Version 2.
top

Required Triggers

There are two conditions for our trigger: we want the tag to fire when our wizardExists variable returns true and we want the tag to fire when an order is completed.
  1. Choose the option to create a new trigger.
  2. Give the trigger a name.
  3. Add a condition for {{event}} equals av.event.order-created.
  4. Click the plus symbol and add another condition for {{wizardExists}} equals true.
  5. Save the trigger.
top

Configuring the Tag

  1. Choose the option to create a new tag.
  2. Give the tag a name.
  3. Choose the DoubleClick Floodlight Sales tag type
  4. Enter your Advertiser ID.
  5. Enter your Group Tag String.
  6. Enter your Activity Tag String.
  7. Set the counting method to ‘Items Sold’.
    A field called 'Quantity' is added.
  8. Set the 'Revenue' parameter to the wizardValue variable.
  9. Set the 'Order ID' parameter to the variable you created for av.order.order_number.
  10. Set the 'Quantity' parameter to the wizardCount variable.
  11. Add a 'Firing Trigger' and choose the trigger you created to fire on av.event.order-created and {{wizardExists}} equals true.
  12. Save the tag.
  13. Preview and debug your container.
  14. Navigate to your website in a new browser window.
  15. Use Google Tag Assistant to confirm that:
    1. The tag is firing only on order completion,
    2. The tag fires only when your product is on the order, and
    3. Only the value for that product is being sent to the advertising platform.
  16. Publish your container and make your tag live.
 

Summary

We created a DoubleClick Floodlight Sales tag that only fires when a specific product exists on the completed order. We created variables to ask the dataLayer to return true if the product exists and to give us the value of that product and the count of the number of admissions for that product.

By re-using this use case, it is easy to fire tags based on your admission products. Just change Wizard of Oz to your product name for each of the three variables. You will need to create this set of three variables for every product that you want to track using this method. If you wanted to do conversion tracking for Wizard of Oz and Billy Elliot, for example, you would need another set of variables specifically for Billy Elliot.