1.2.25 • Published 2 years ago

@thg-altitude/tracking v1.2.25

Weekly downloads
-
License
ISC
Repository
github
Last release
2 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

2 years ago

1.2.24

2 years ago

1.2.23

2 years ago

1.2.22

2 years ago

1.2.21

2 years ago

1.2.20

2 years ago

1.2.19

2 years ago

1.2.18

2 years ago

1.2.17

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago