1.2.25 • Published 7 months ago

@thg-altitude/tracking v1.2.25

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

7 months ago

1.2.24

7 months ago

1.2.23

7 months ago

1.2.22

7 months ago

1.2.21

7 months ago

1.2.20

7 months ago

1.2.19

7 months ago

1.2.18

7 months ago

1.2.17

7 months ago

1.2.16

7 months ago

1.2.15

7 months ago

1.2.14

7 months ago

1.2.13

7 months ago

1.2.12

7 months ago

1.2.11

7 months ago

1.2.10

7 months ago

1.2.9

7 months ago

1.2.8

7 months ago

1.2.7

7 months ago

1.2.6

7 months ago

1.2.5

7 months ago

1.2.4

7 months ago

1.2.3

7 months ago

1.2.2

7 months ago

1.2.1

7 months ago

1.2.0

7 months ago

1.1.9

7 months ago

1.1.8

7 months ago

1.1.7

7 months ago

1.1.6

7 months ago

1.1.5

8 months ago

1.1.4

8 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago