1.2.25 • Published 3 years ago

@thg-altitude/tracking v1.2.25

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Tracking SDK

A reusable package for managing Ingenuity GA/BI/UA events.

Installation

    <script is:inline>
      window.Tracker = {
        store: {
          get(k) {
            return Tracker.store[k]
          },
          set(k,v) {
            return Tracker.store[k] = Tracker.store[k] ? Object.assign(Tracker.store[k], v) : v
          }
        }
      }
    </script>
    <script src="https://unpkg.com/@thg-altitude/tracking@1.0.4/index.js" async></script>

How-to-use

Events can be triggered in to ways: 1. Data Attributes

<button data-track="addToCard" data-track-push="yourStoreKey"/>
  1. Handlers
Tracker.handlers.addToCart({ store: 'yourStoreKey' })

In both cases when you're dependant on enriching the tracking event with meta data (e.g. product page data, list page data, basket contents) you will need to populate a store.

You can populate at store at any time by running the following:

Tracker.store.set('yourStoreKey', {
  ...
})

In the event that objects in the store need to change over time (for e.g. a custom changes quantities for the product after initial load) the store supports records being upserted as long as the keys are the same.

Events

eventstoresupported
addToCart{ product }
selectItem{ product }

Store Objects

Product

An structure for product would be the following.

{
  item_name: "Donut Friday Scented T-Shirt",
  item_id: "67890",
  price: 33.75,
  item_brand: "Google",
  item_category: "Apparel",
  item_category2: "Mens",
  item_category3: "Shirts",
  item_category4: "Tshirts",
  item_variant: "Black",
  item_list_name: "Search Results",
  item_list_id: "SR123",
  index: 2,
  quantity: 1
}

Publishing

In order to publish a new version you will need a local .npmrc to publish to @thg-altitude.

Update the package.json with the new version before running npm publish

1.2.25

3 years ago

1.2.24

3 years ago

1.2.23

3 years ago

1.2.22

3 years ago

1.2.21

3 years ago

1.2.20

3 years ago

1.2.19

3 years ago

1.2.18

3 years ago

1.2.17

3 years ago

1.2.16

3 years ago

1.2.15

3 years ago

1.2.14

3 years ago

1.2.13

3 years ago

1.2.12

3 years ago

1.2.11

3 years ago

1.2.10

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago