Use Google Tag Manager to Send Coupon Manager Redemptions

About this task

You can use a Google Tag Manager tag to send the email, coupon, and order data to Bronto when your contacts redeem a coupon.
Note: These instructions assume that you have implemented a Google Tag Manager data layer with a standard purchase action object.

Procedure

  1. Get started by creating user defined variables. We will first create the EC—Grand Total variable.
    1. Within Google Tag Manager, go to Variables.
    2. Click New to create a new user-defined variable.
    3. Click to choose a variable type. Select Data Layer Variable.
    4. Add your data layer variable name: ecommerce.purchase.actionField.revenue.
    5. Name your variable EC - Grand Total.
    6. Click Save.
  2. Create the EC—Order ID variable.
    1. Within Google Tag Manager, go to Variables.
    2. Click New to create a new user-defined variable.
    3. Click to choose a variable type. Select Data Layer Variable.
    4. Add your data layer variable name: ecommerce.purchase.actionField.id.
    5. Name your variable EC - Order ID.
    6. Click Save.
  3. Create the EC—Coupon variable.
    1. Within Google Tag Manager, go to Variables.
    2. Click New to create a new user-defined variable.
    3. Click to choose a variable type. Select Data Layer Variable.
    4. Add your data layer variable name: ecommerce.purchase.actionField.coupon.
    5. Name your variable EC - Coupon.
    6. Click Save.
  4. You can follow the same process used for the EC—Grand Total, EC—Order ID, and EC—Coupon variables for additional ecommerce variables such as subtotal and discount.
  5. You will need to pass an additional field, EC - Email, to Google Tag Manager that contains the email address of the customer. One way to do this is by adding a new dataLayer variable. ( See Google's documentation on adding data layer variables to a page).
  6. Once you have added an Email variable to the dataLayer, you will be able to create a new user-defined Google Tag Manager variable using the same process you used for the EC—Grand Total, EC—Order ID, and EC—Coupon variables. For example, let's say that you have added email to the dataLayer using the code dataLayer.push({'customerEmail': 'james@example.com'}); . You would then follow these steps to add the EC - Email variable.
    1. Within Google Tag Manager, go to Variables.
    2. Click New to create a new user-defined variable.
    3. Click to choose a variable type. Select Data Layer Variable.
    4. Add your data layer variable name: customerEmail.
    5. Name your variable EC - Email.
    6. Click Save.
  7. You need to create a trigger to signal that a transaction has taken place next. For this example, we will assume that your site redirects customers to complete.html after an order is complete. To get started, click Triggers in Google Tag Manager.
    1. Click New to create a new trigger.
    2. Click to choose a trigger type. Select Page View.
    3. Select Some Page Views for the This trigger fires on field.
    4. Select to fire the trigger when Page URL contains the path complete.html.
    5. Name your trigger and click Save.
  8. You will need to create a tag next. Before you can create your tag, you need to copy JavaScript from Bronto.
    1. In Bronto, go to Commerce > Coupon Manager.
    2. Click Redemption Settings.
    3. Click Redemption JavaScript Snippet.
    4. Copy the script provided, including the opening and closing <script> tags, and paste it into a code editor.
    5. In your code sample, replace <value-or-selector-definition> with the following Google Tag Manager variables. Your code sample will have a different value where placeholdervalue is. You can remove orderDiscount if you are not using a corresponding optional variable.
      <script type="text/javascript" src="https://c.bron.to/assets/coupon/js/bcm.js"></script>
      <script type="text/javascript">
      __bcm.redeemCoupon("placeholdervalue", {
      	email: {{EC - Email}},
      	coupon: {{EC - Coupon}},
      	orderId: {{EC - Order ID}},
      	orderSubtotal: {{EC Grand Total}}
      });
      </script>
  9. Return to Google Tag Manager. Click Tags to start building your tag.
    1. Click New.
    2. Click Tag Configuration and select the tag type Custom HTML.
    3. Enter your modified script into the HTML field.
    4. Click inside the Triggering box.
    5. Select the trigger you created previously for the path that your customers land on after a purchase.

    6. Name your tag (example: Bronto Coupon Manager Redemption) and Save.
  10. Click Submit.
  11. Name your version (example: First Deploy) and add a description.
  12. Click Publish to make your new tag live.