Analytics configuration

A WebLink Widgets installation can be configured to track events coming from customer interactions with your analytics provider of choice.

The standard snippet generated by WebLink builder includes an empty example for analyticsHandler:

var webLinkConfig = {
    portalAddress: 'myinstance-portal.administrateweblink.com',
    hashRouting: false,
    timezone: 'Europe/London',
    analyticsHandler: function (event) {
        // Send event to the analytics provider.

        // For example, if using Google Tag Manager,
        //   1. Ensure snippet is added to your website according to the [instructions](https://developers.google.com/tag-platform/tag-manager/web)
        //   2. Then call: window.dataLayer.push(event)
    }
};

var webLink = new window.WebLink(webLinkConfig);

The event passed to this function is an object describing the user interaction. See the following examples.

Page View

Triggered by:

  • Viewing a Page
{
  "event": "page_view",
  "user_id": "SOME_USER_IDENTIFIER",
  "page_location": "https://myinstance-portal.administrateweblink.com/cart",
  "page_title": "My Instance - Cart",
  "language": "en-US"
}

Product View

Triggered by:

  • Viewing a Course Details Page
  • Viewing a Learning Path Page
{
  "event": "view_item",
  "user_id": "SOME_USER_IDENTIFIER",
  "page_location": "https://myinstance-portal.administrateweblink.com/first-aid-course",
  "page_title": "My Instance - First Aid",
  "language": "en-US",
  "ecommerce": {
    "currency": "EUR",
    "value": 20.00,
    "items": [
      {
        "item_id": "Q291cnNlVGVtcGxhdGU6MQ==",
        "item_name": "First Aid Course",
        "item_category": "Emergency",
        "item_category2": "First Aid",
        "item_category3": null,
        "item_category4": null,
        "item_category5": null,
        "item_variant": "course",
        "price": 20.00,
        "code": "ABC-123",
        "learning_tags": ["emergency", "first-aid", "medical"],
        "account_associations": [
          {
            "name": "Selling 2000",
            "type": "Reseller"
          }
        ],
        "is_featured": true
      }
    ]
  }
}

Search

Triggered by:

  • Typing in the Catalog search box
  • Using the Catalog Learning category menu
  • Filtering a Course's Event List
  • Filtering a Learning Path's objective selector
{
  "event": "search",
  "user_id": "SOME_USER_IDENTIFIER",
  "page_location": "https://myinstance-portal.administrateweblink.com/courses/first-aid",
  "page_title": "My Instance - First Aid",
  "language": "en-US",
  "ecommerce": {
    "search_term": "foobar",
    "search_type": "events",
    "filters": [
      {
        "field": "locationId",
        "operation": "eq",
        "value": "TG9jYXRpb246Mg=="
      },
      {
        "field": "remainingPlaces",
        "operation": "ge",
        "value": "1"
      }
    ],
    "result_count": 5
  }
}

Cart

In the example events below, we clarify the monetary amounts in the ecommerce object:

  • subtotal: the total cart amount excluding any tax or discounts
  • discount: the total amount of discount applied (before tax)
  • tax: the total amount across all tax types applicable to the order (after discount)
  • value: the total cart value after discounts and taxes have been applied
  • gift_voucher_value: if a Gift Voucher was used, the amount deducted from it to cover the order (or 0)

Add Item

Triggered by:

  • Adding an item to their cart
  • Increasing a cart item’s quantity (in this case quantity below will be the increase, i.e. the difference between the previous and the new quantity)
{
  "event": "add_to_cart",
  "user_id": "SOME_USER_IDENTIFIER",
  "page_location": "https://myinstance-portal.administrateweblink.com/cart",
  "page_title": "My Instance - My Basket",
  "language": "en-US",
  "ecommerce": {
    "transaction_id": "T3Bwb3J0dW5pdHk6NjQ=",
    "currency": "EUR",
    "value": 20.00,
    "tax": 0,
    "items": [
      {
        "item_id": "Q291cnNlVGVtcGxhdGU6MQ==",
        "item_name": "First Aid Course",
        "item_category": "Emergency",
        "item_category2": "First Aid",
        "item_category3": null,
        "item_category4": null,
        "item_category5": null,
        "item_variant": "course",
        "price_level": "Normal",
        "price": 20.00,
        "tax": 0,
        "quantity": 1,
        "location_id": "TG9jYXRpb246Mg==",
        "location_name": "New York",
        "code": "ABC-123",
        "learning_tags": ["emergency", "first-aid", "medical"],
        "account_associations": [
          {
            "name": "Selling 2000",
            "type": "Reseller"
          }
        ],
        "is_featured": true,
        "start_datetime": "2024-02-06T17:10:57.734Z"
      }
    ]
  }
}

Remove Item

Triggered by:

  • Removing an item from their cart (ie: removes an item or decreases the quantity of an item)
  • Decreasing a cart item’s quantity (in this case quantity below will be the decrease, i.e. the difference between the previous and the new quantity)
{
  "event": "remove_from_cart",
  "user_id": "SOME_USER_IDENTIFIER",
  "page_location": "https://myinstance-portal.administrateweblink.com/cart",
  "page_title": "My Instance - My Basket",
  "language": "en-US",
  "ecommerce": {
    "transaction_id": "T3Bwb3J0dW5pdHk6NjQ=",
    "currency": "EUR",
    "value": 20.00,
    "tax": 0,
    "items": [
      {
        "item_id": "Q291cnNlVGVtcGxhdGU6MQ==",
        "item_name": "First Aid Course",
        "item_category": "Emergency",
        "item_category2": "First Aid",
        "item_category3": null,
        "item_category4": null,
        "item_category5": null,
        "item_variant": "course",
        "price_level": "Normal",
        "price": 20.00,
        "tax": 0,
        "quantity": 1,
        "location_id": "TG9jYXRpb246Mg==",
        "location_name": "New York",
        "code": "ABC-123",
        "learning_tags": ["emergency", "first-aid", "medical"],
        "account_associations": [
          {
            "name": "Selling 2000",
            "type": "Reseller"
          }
        ],
        "is_featured": true,
        "start_datetime": "2024-02-06T17:10:57.734Z"
      }
    ]
  }
}

View Cart

Triggered by:

  • Viewing the Cart Page
{
  "event": "view_cart",
  "user_id": "SOME_USER_IDENTIFIER",
  "page_location": "https://myinstance-portal.administrateweblink.com/cart",
  "page_title": "My Instance - My Basket",
  "language": "en-US",
  "ecommerce": {
    "transaction_id": "T3Bwb3J0dW5pdHk6NjQ=",
    "currency": "EUR",
    "value": 20.00,
    "tax": 0,
    "items": [
      {
        "item_id": "Q291cnNlVGVtcGxhdGU6MQ==",
        "item_name": "First Aid Course",
        "item_category": "Emergency",
        "item_category2": "First Aid",
        "item_category3": null,
        "item_category4": null,
        "item_category5": null,
        "item_variant": "course",
        "price_level": "Normal",
        "price": 20.00,
        "tax": 0,
        "quantity": 1,
        "location_id": "TG9jYXRpb246Mg==",
        "location_name": "New York",
        "code": "ABC-123",
        "learning_tags": ["emergency", "first-aid", "medical"],
        "account_associations": [
          {
            "name": "Selling 2000",
            "type": "Reseller"
          }
        ],
        "is_featured": true,
        "start_datetime": "2024-02-06T17:10:57.734Z"
      }
    ]
  }
}

Checkout

Progression (booker / learner / payment)

Triggered by:

  • Navigating to the checkout
  • Navigating to a step within the checkout
{
  "event": "begin_checkout | add_shipping_info | add_learner_info | add_payment_info",
  "user_id": "SOME_USER_IDENTIFIER",
  "page_location": "https://myinstance-portal.administrateweblink.com/checkout",
  "page_title": "My Instance - Checkout",
  "language": "en-US",
  "ecommerce": {
    "transaction_id": "T3Bwb3J0dW5pdHk6NjQ=",
    "payment_type": "card",
    "currency": "EUR",
    "subtotal": 20.00,
    "discount": 5.00,
    "value": 15.00,
    "tax": 0,
    "coupon": "SUMMER_SALE",
    "items": [
      {
        "item_id": "Q291cnNlVGVtcGxhdGU6MQ==",
        "item_name": "First Aid Course",
        "item_category": "Emergency",
        "item_category2": "First Aid",
        "item_category3": null,
        "item_category4": null,
        "item_category5": null,
        "item_variant": "course",
        "price_level": "Normal",
        "price": 20.00,
        "tax": 0,
        "quantity": 1,
        "location_id": "TG9jYXRpb246Mg==",
        "location_name": "New York",
        "code": "ABC-123",
        "learning_tags": ["emergency", "first-aid", "medical"],
        "account_associations": [
          {
            "name": "Selling 2000",
            "type": "Reseller"
          }
        ],
        "is_featured": true,
        "start_datetime": "2024-02-06T17:10:57.734Z"
      }
    ]
  }
}

Purchase complete

Triggered by:

  • Landing on the order confirmation page
{
  "event": "purchase",
  "user_id": "SOME_USER_IDENTIFIER",
  "page_location": "https://myinstance-portal.administrateweblink.com/checkout",
  "page_title": "My Instance - Order complete",
  "language": "en-US",
  "ecommerce": {
    "transaction_id": "T3Bwb3J0dW5pdHk6NjQ=",
    "payment_type": "card",
    "currency": "EUR",
    "subtotal": 20.00,
    "discount": 5.00,
    "gift_voucher": "GC12345",
    "gift_voucher_value": 5.00,
    "value": 10.00,
    "tax": 0,
    "coupon": "SUMMER_SALE",
    "items": [
      {
        "item_id": "Q291cnNlVGVtcGxhdGU6MQ==",
        "item_name": "First Aid Course",
        "item_category": "Emergency",
        "item_category2": "First Aid",
        "item_category3": null,
        "item_category4": null,
        "item_category5": null,
        "item_variant": "course",
        "price_level": "Normal",
        "price": 20.00,
        "tax": 0,
        "quantity": 1,
        "location_id": "TG9jYXRpb246Mg==",
        "location_name": "New York",
        "code": "ABC-123",
        "learning_tags": ["emergency", "first-aid", "medical"],
        "account_associations": [
          {
            "name": "Selling 2000",
            "type": "Reseller"
          }
        ],
        "is_featured": true,
        "start_datetime": "2024-02-06T17:10:57.734Z"
      }
    ]
  }
}