Set up sales attribution tracking pixel (links and discount codes)

The Sales Attribution Tracking Pixel is a way for your brand to track link attribution and purchase orders/discount code use as people visit your eCommerce store.  For every ambassador that shares their unique links and/or discount codes, you will be able to track the number of sales that the individual referred.

Overview

To set up sales attribution tracking, please complete the following steps:

  • Step 1: Get Your Access Token
  • Step 2: Add the Link Tracking Pixel
  • Step 3: Integrate Order Tracking
  • Step 4: End to End Testing

See Additional Help Articles by eCommerce Platform


Step 1. Get Your Access Token

Generate a "Sales Attribution" access token to be included in your JavaScript code.  Go to your brand settings to create a new token.


Step 2. Add The Link Tracking Pixel

To add the tracking pixel to your store you'll need to add the following JavaScript snippet on every page of your site so the Wooly system can capture referred visits.  Embed this just before  </body> tag in your HTML. (this is typically done in the main site template so it's auto-magically applied to every page)

<!-- Wooly Analytics -->
<script async type="application/javascript" src="https://saa.wooly.com/wooly-analytics.js?token=ACCESS_TOKEN"></script>

*Set your access token: be sure to replace the ACCESS_TOKEN placeholder with your sales attribution token.

*Track across sub domains: does your eCommerce setup involve multiple sub domains?  If so, you'll need to enable cookie tracking.


Step 3. Integrate Order Tracking (advanced)

Send specific order data to us so we can capture the order data and, optionally, the new customer's information.  Sending Wooly the customer information is valuable in forming an attribution data graph of who referred who.  Wooly also links social listening and campaign participation data to customers along with other useful information that can all tie back to how the customer first joined your herd.

JavaScript Code on Order Confirmation Page

Add the following JavaScript code on your order confirmation page and replace the placeholders with variables/properties in your code.  The minimum required parameters to capture an order is the order Id with a referral Id or discount code. The referral Id is sent automatically by the main tracking pixel so you don't have to worry about it in this script.  All other fields are optional but recommended.  The more you send us the more valuable your data is in the Wooly CRM and analytics.  It's important to note that if you do send the customer info (name and email) then the pixel will auto create new contact profiles in Wooly for new customers even if they were not referred.  This allows you to setup triggered events to engage with new customers.  For more details see our API Documentation

This first example is a preferred option by many developers.  Be sure to replace the mocked data in this script with proper objects provided by your eCommerce platform.

<!-- Wooly Order Submission: START -->
<script type="application/javascript">
  function submitOrder() {
    if (WoolyAnalytics) {
      WoolyAnalytics.set({
        orderId: "123456",
        discountCodes: ["sale2020", "janedoe123"],
        currency: "USD",
        totalPrice: 29.99,
        firstName: "John",
        lastName: "Doe",
        email: "john.doe@email.com"
      });
      WoolyAnalytics.emit();
    }
  }
  let script = document.createElement("script");
  script.addEventListener("load", submitOrder);
  script.src = "https://saa.wooly.com/wooly-analytics.js?token=ACCESS_TOKEN";
  document.body.appendChild(script);
</script>
<!-- Wooly Order Submission: END -->

*Set your Access Token: be sure to replace the ACCESS_TOKEN placeholder with your sales attribution token.

For more complex scenarios you may need to set each property value individually in different parts of your code as shown in this example.  Again, be sure to replaced mocked data with objects provided by your eCommerce platform.

WoolyAnalytics.set({orderId: "123456"});
WoolyAnalytics.set({discountCodes: ["sale2020", "janedoe123"]});
WoolyAnalytics.set({currency: "USD", totalPrice: 29.99}); // Example: 2 fields at a time
// Same for firstName, lastName, email
WoolyAnalytics.emit();

Step 4. End to End Testing

You're done with the integration! Now it's time to test by following a referral link to your online store and completing an order.  

  1. First, go to your online store with our query string parameter "wly_id" to verify the link tracking is working. 
    1. Example:  https://yourdomain.com/?wly_id=referralId
      1. You can get a real referral Id from a contact in your Wooly portal and use that to load your online store web page.
    2. Reload that contact's profile in Wooly to verify the "Link Clicks" stats counted your test. (see image above)
  2. For each of the following steps you can check the stats in your dashboard and navigate to the "Sales Attribution" report to verify referral link and discount code usage are being tracked properly.
  3. Next, submit a test order to verify that the order data was successfully sent and associated by referral Id.
  4. Next, submit a test order using a discount code to verify that the order data was successfully sent and associated by discount code usage.

Troubleshooting Tips

Some tests are failing? Go here for help with troubleshooting

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us