Documentation
Documentation (JA)
Documentation (JA)
  • Documentation
  • Products
    • Fanplayr Targeting Portal
    • Fanplayr 360
    • PrivacyID
    • SiteSpeed
  • Features
    • Merchandising
    • Security
    • SMS
    • Web Push Notifications
      • Direct Integration Guide
      • Popup Integration Guide
      • Imaging Sizing Guide
    • Data Residency
  • Fanplayr Targeting
    • E-Commerce Integrations
      • BigCommerce
      • CommerceV3
      • Magento 1
        • Getting Started
        • Configuration
      • Magento 2
      • Miva Merchant
      • PrestaShop
      • Salesforce Commerce Cloud
      • Shopify
      • Volusion
      • VTEX
      • VTEX IO
    • Custom Integration
      • Page tracking
        • Apply to cart
        • Session offers
      • Order tracking
      • Data types
        • CartAction
        • Product
      • Data Layer API
      • Enhanced user identification
        • Manual Integration
      • Segmentation as a service
      • Lazy loading
      • Page caching
      • Tag managers
      • Single page apps
      • Custom data for verticals
        • Travel
    • Pixel Integration
    • ESP Integrations
    • Link Decoration
    • User Management
      • User Identity
      • User Properties
  • Other
    • CSP & Domains
Powered by GitBook
On this page
  • Tracking Code Template
  • Configuration
  • version
  • accountKey
  • storeDomain
  • connect
  • Tracking variables
  • orderId
  • orderNumber
  • gross
  • total
  • discount
  • discountCode
  • shipping
  • tax
  • currency
  • orderEmail
  • firstName
  • lastName
  • customerEmail
  • customerId
  • products
  • cartAction
  • Custom Data
  • Example

Was this helpful?

  1. Fanplayr Targeting
  2. Custom Integration

Order tracking

Tracks orders placed on your site.

Fanplayr can easily track conversions made on your eCommerce store, which along with our user behavior tracking, can be used to analyze your store and identify opportunities to improve your business through targeting non-converting customer profiles.

Tracking Code Template

The following Javascript code template must be placed on the order confirmation page to track conversions. This should be the page customers view after the order process is complete. For example, this may a page your customers are returned to after an external payment gateway such as PayPal.

<!-- start Fanplayr Conversion Tracking -->
<script>
(function(d, w, s) {
  if ( !w.fp_sales_orders ) {
    w.fp_sales_orders = {
      version: 3,
      accountKey: '',
      storeDomain: '',
      data: {
        orderId: '',
        orderNumber: '',
        gross: 0.00,
        total: 0.00,
        discount: 0.00,
        discountCode: '',
        shipping: 0.00,
        tax: 0.00,
        currency: '',
        orderEmail: '',
        firstName: '',
        lastName: '',
        customerEmail: '',
        customerId: '',
        products: [
          {
            id: '',
            sku: '',
            price: 0.00,
            qty: 1,
            name: ''
          }
        ],
        cartAction: 'override',
        custom_data: {
          // ...
        }
      }
    };
    var js = d.createElement(s);
    var fjs = d.getElementsByTagName(s)[0];
    js.async = true;
    js.src = 'https://cdn.fanplayr.com/client/production/fp_custom_orders.js';
    fjs.parentNode.insertBefore(js, fjs);
  }
})(document, window, 'script');
</script>
<!-- end Fanplayr Conversion Tracking -->

Configuration

version

  • Type: integer

  • Scope: All pages

  • Required

Tracking format version identifier used by the Fanplayr platform. Must be set to 3.

accountKey

  • Type: string

  • Scope: All pages

  • Required

Unique string used identify your account with the Fanplayr platform.

storeDomain

  • Type: string

  • Scope: All pages

  • Default: Value of window.location.hostname

Can be used to optionally override the domain that Fanplayr associates with the order.

connect

  • Type: object

  • Scope: All pages

  • Default: undefined

Tracking variables

The following variables must be provided in the data object. Example:

{
  version: 3,
  accountKey: '7e43c8cddccade2b95ee5286ba89758a',
  data: {
    orderId: '005921',
    orderNumber: '005921',
    gross: 89.90,
    total: 79.90,
    discount: 10.00
  }
}

orderId

  • Type: string

  • Required

The unique order identifier that is used internally by your system. This can be used later to reference transactions in your internal system.

This may be different from orderNumber, which is the order confirmation number provided to your users.

orderNumber

  • Type: string

  • Required

The order confirmation number as seen by the user. This may be the same or different to orderId.

gross

  • Type: float

  • Required

The total value (in the specified currency) of the items in the order. More specifically, the sum total of the items in the order before discounts, shipping and taxes.

total

  • Type: float

  • Required

This is the total value (in the specified currency) of the items in the order. More specifically, the sum total of the items in the order before shipping and taxes, but after discounts.

discount

  • Type: float

  • Required

This is the total value of discounts applied to the cart. This means discounts such as free shipping or shipping discounts should not change this value.

discountCode

  • Type: string

  • Required

The discount code applied to the order (if any). If there are multiple discount codes applied, separated them with commas.

shipping

  • Type: float

  • Default: 0

The total shipping amount, after any shipping-specific discount is applied.

tax

  • Type: float

  • Default: 0

The total of all taxes applied to the order.

currency

  • Type: string

  • Default: "USD"

orderEmail

  • Type: string

The email address the user provided for the order. This may be different from customerEmail.

firstName

  • Type: string

The first name of the user who placed the order. E.g. "John".

lastName

  • Type: string

The last name of the user who placed the order. E.g. "Smith".

customerEmail

  • Type: string

The email address of the current user.

customerId

  • Type: string

This is an identifier of the user that is internal to your site. This is used to track new and repeat users.

products

An array of objects (or JSON) representing the products in the order.

cartAction

  • Default: "override"

This is a special variable that determines how Fanplayr will treat cart-related data for the current tracking call. It can be used to carry forward cart details (total value in cart, products in cart etc) from the previous page view if they are unavailable for the current tracking call.

Custom Data

You can track additional order details as custom data using the custom_data object:

{
  accountKey: '<ACCOUNT_ID>',
  data: {
    // ...
  },
  custom_data: {
    // Add key/value pairs of additional details to track
    order_notes: 'Please leave at front door'
  }
}

Example

The following example could be used to track:

  • An order totaling $79.90 USD after the $10 "SUMMER10" discount is applied.

  • Consisting of a single product:

    • Red Shoes, priced at $89.90

<script>
(function(d, w, s) {
  if ( !w.fp_sales_orders ) {
    w.fp_sales_orders = {
      version: 3,
      accountKey: '7e43c8cddccade2b95ee5286ba89758a',
      storeDomain: 'example.com',
      data: {
        orderId: '005921',
        orderNumber: '005921',
        gross: 89.90,
        total: 79.90,
        discount: 10.00,
        discountCode: 'SUMMER10',
        shipping: 0.00,
        tax: 0.00,
        currency: 'USD',
        orderEmail: 'john.smith@gmail.com',
        firstName: 'John',
        lastName: 'Smith',
        customerEmail: 'john.smith@gmail.com',
        customerId: '10204723',
        products: [
          {
            id: 'WRS001',
            sku: 'WRS001',
            price: 89.90,
            qty: 1,
            name: 'Red Shoes'
          }
        ]
      }
    };
    var js = d.createElement(s);
    var fjs = d.getElementsByTagName(s)[0];
    js.async = true;
    js.src = 'https://cdn.fanplayr.com/client/production/fp_custom_orders.js';
    fjs.parentNode.insertBefore(js, fjs);
  }
})(document, window, 'script');
</script>
PreviousSession offersNextData types

Was this helpful?

Some stores may use different domains for their checkout system. E.g. Users may browse your store at , but the checkout and orders may be placed at . In this case, it would be necessary to set storeDomainto "example.com" (the same domain linked to your Fanplayr campaign) so that the Fanplayr platform can seamlessly track the user and orders they place across these domains.

The path to the server-side page for .

The currency code of the product and order values being tracked.

Type: | string

Type:

https://www.example.com
https://www.checkout.com/example
Enhanced User Identification
ISO 4217
Array<Product>
CartAction