new AnalyticsObserver(dataLayer, state)
Observer for the UpsellStore that updates the data layer for Google Tag Manager.
Stores a copy of the state so it can compare the previous and updated state.
Dispatches custom events when the user takes an action, such as viewing, accepting or declining an offer.
Events contain metadata about the post-purchase flow and offer.
Implements the Observer design pattern. See https://en.wikipedia.org/wiki/Observer_pattern
Parameters:
| Name | Type | Description |
|---|---|---|
dataLayer |
Array.<Object> | Data layer, as specified by Google Tag Manager https://developers.google.com/tag-manager/devguide |
state |
Object | The initial state of the UpsellStore |
- Source:
Methods
(static) update(newState, oldState) → {void}
Update the data layer with the latest flow data.
Dispatches events for the following: Viewed offer, Accepted offer, and Declined offer, and Upsell Completed.
Intended to be used as the callback for a Vue watcher. See https://vuejs.org/guide/essentials/watchers.html
Parameters:
| Name | Type | Description |
|---|---|---|
newState |
Object | The new state of the UpsellStore |
oldState |
Object | The previous state of the UpsellStore |
- Source:
Returns:
- Type
- void