marketing.js
Advanced tools
Comparing version 0.0.3 to 0.0.6
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.marketing=e():t.marketing=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){return!e||"object"!==o(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function l(t,e,n){return e&&s(t.prototype,e),n&&s(t,n),t}function h(){return parseInt((new window.Date).getTime()/1e3,10)}n.r(e),n.d(e,"getCurrentTime",function(){return h}),n.d(e,"getQueryParam",function(){return f}),n.d(e,"storageRead",function(){return p}),n.d(e,"storageWrite",function(){return m}),n.d(e,"Touchpoint",function(){return d}),n.d(e,"Channel",function(){return g}),n.d(e,"URLMatchingChannel",function(){return v}),n.d(e,"ReferrerMatchingChannel",function(){return y}),n.d(e,"SearchEngineChannel",function(){return w}),n.d(e,"AttributionItem",function(){return b}),n.d(e,"AttributionModel",function(){return k}),n.d(e,"LastTouchAttributionModel",function(){return O}),n.d(e,"AttributionEngine",function(){return P});var f=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=new RegExp("(^|&|\\?)".concat(t,"=(.*?)($|&)"),"ig").exec(e||window.location.search);return null!==n&&n.length>1?n[2]:null};function p(t){var e="",n=null;try{e=window.localStorage.getItem(t)}catch(t){}if(!e){var o=window.document.cookie.match(new RegExp("(^| )".concat(t,"=([^;]+)")));o&&o.length>1&&(e=o[2])}try{n=window.JSON.parse(e)}catch(t){}return n}function m(t,e){var n="";"string"!=typeof e&&(n=window.JSON.stringify(e));try{window.localStorage.setItem(t,n)}catch(e){window.document.cookie="".concat(t,"=").concat(n,";path=/;")}}var d=function(){function t(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h();c(this,t),this.channel=e,this.value=n,this.timestamp=o}return l(t,[{key:"getChannel",value:function(){return this.channel}},{key:"getValue",value:function(){return this.value}},{key:"getTimestamp",value:function(){return this.timestamp}},{key:"updateTimestamp",value:function(){this.timestamp=h()}},{key:"toJSON",value:function(){return{c:this.channel.getId(),v:this.value,t:this.timestamp}}}],[{key:"fromJSON",value:function(e,n){if(!n||void 0===n.c||void 0===n.t)throw new Error('Touchpoint.fromJSON: expected a string in form of {"c":"id","v":"value","t":1234567890}',n);var o=e.getChannelById(n.c);if(!o)throw new Error('Touchpoint.fromJSON: channel "'.concat(n.c,'" not found in provided engine'));return new t(o,n.v,n.t)}}]),t}(),g=function(){function t(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c(this,t),this.id=e,this.label=n,this.options=o,void 0===this.options.canOverwrite&&(this.options.canOverwrite=!1),void 0===this.options.isFirstViewOnly&&(this.options.isFirstViewOnly=!1)}return l(t,[{key:"getId",value:function(){return this.id}},{key:"getLabel",value:function(){return this.label}}]),t}(),v=function(t){function e(t,n,o,u,a){var s;return c(this,e),(s=i(this,r(e).call(this,t,n,a))).matchPattern=o,s.valueParamName=u,s}return u(e,g),l(e,[{key:"execute",value:function(){var t=null;if("string"==typeof this.matchPattern)t=null!==f(this.matchPattern);else if(this.matchPattern instanceof RegExp)t=window.location.search.match(this.matchPattern);else if("object"===o(this.matchPattern)){for(var e=Object.keys(this.matchPattern),n=[],i=0;i<e.length;i+=1){var r=this.matchPattern[e[i]],u=f(e[i]);n.push("boolean"==typeof r?!!u===r:u===r)}t=-1===n.indexOf(!1)}if(t){var a=null;return"string"==typeof this.valueParamName&&(a=decodeURIComponent(f(this.valueParamName))),new d(this,a)}return null}}]),e}(),y=function(t){function e(t,n,o,u){var a;return c(this,e),(a=i(this,r(e).call(this,t,n,u))).matchPattern=o,a}return u(e,g),l(e,[{key:"execute",value:function(){var t=this.matchPattern;if((this.matchPattern instanceof RegExp||"function"==typeof this.matchPattern)&&(t=[this.matchPattern]),t&&t.length>0)for(var e=0;e<t.length;e+=1)if(t[e]instanceof RegExp&&window.document.referrer.match(t[e])||"function"==typeof t[e]&&t[e](window.document.referrer))return new d(this);return null}}]),e}(),w=function(t){function e(){return c(this,e),i(this,r(e).apply(this,arguments))}return u(e,g),l(e,[{key:"execute",value:function(){for(var t=0;t<e.searchEngineRules.length;t+=1){var n=e.searchEngineRules[t];if(window.document.referrer.match(n.rule))return new d(this,n.valueParam?f(n.valueParam):"")}return null}}]),e}();w.searchEngineRules=[{rule:/(\.)?(google|googlesyndication|googleadservices|naver|bing|yahoo|yandex|daum|baidu|myway|ecosia|ask|dogpile|sogou|seznam|aolsvc|altavista|duckduckgo|mywebsearch|wow|webcrawler|infospace|blekko|docomo)(?=\.[a-z.]{2,5})/gi,valueParam:!1},{rule:/(\.)?(goo\.gl)/gi,valueParam:!1},{rule:/^android-app:\/\/com\.google\.android/gi,valueParam:!1}];var b=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;c(this,t),this.touchpoint=e,this.weight=n}return l(t,[{key:"getTouchpoint",value:function(){return this.touchpoint}},{key:"getWeight",value:function(){return this.weight}}]),t}(),k=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2592e3;c(this,t),this.touchpointLifetime=e}return l(t,[{key:"execute",value:function(){throw new Error("AttributionModel.execute must be implemented in overridden subclasses")}}]),t}(),O=function(t){function e(){return c(this,e),i(this,r(e).apply(this,arguments))}return u(e,k),l(e,[{key:"execute",value:function(){var t=this,e=null;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(function(n){n.getTimestamp()>h()-t.touchpointLifetime&&(null===e||n.getChannel().options.canOverwrite)&&(e=n)}),e?[new b(e,100)]:[]}}]),e}(),P=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1800,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"gktp";c(this,t),this.model=e,this.channelConfig=n,this.cookieName=i,this.visitDuration=o,this.touchpointHistory=[],this.lastTouchTimestamp=0;var r=p(this.cookieName);try{var u=JSON.parse(r);u&&this.restoreFromData(u)}catch(t){}}return l(t,[{key:"execute",value:function(){for(var t=h(),e=null,n=0;n<this.channelConfig.length;n+=1){var o=this.channelConfig[n];if(e=o.execute()){var i=this.touchpointHistory.length>0?this.touchpointHistory[this.touchpointHistory.length-1]:null;o.options.isFirstViewOnly&&t-this.lastTouchTimestamp<this.visitDuration?e=null:i&&i.getValue()===e.getValue()&&i.getChannel().getId()===e.getChannel().getId()?i.updateTimestamp():this.touchpointHistory.push(e);break}}return this.lastTouchTimestamp=t,m(this.cookieName,JSON.stringify(this.saveToData())),e}},{key:"getAttributionItems",value:function(){return this.model.execute(this.getTouchpointHistory())}},{key:"getTouchpointHistory",value:function(){return this.touchpointHistory}},{key:"getChannelById",value:function(t){for(var e=0;e<this.channelConfig.length;e+=1)if(this.channelConfig[e].getId()===t)return this.channelConfig[e];return null}},{key:"restoreFromData",value:function(t){var e=this;t&&(this.lastTouchTimestamp=t.lt,this.touchpointHistory=[],t.e.forEach(function(t){var n=d.fromJSON(e,t);n&&e.touchpointHistory.push(n)}))}},{key:"saveToData",value:function(){return{e:this.touchpointHistory.map(function(t){return t.toJSON()}),lt:this.lastTouchTimestamp}}}]),t}()}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.marketing=e():t.marketing=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){return!e||"object"!==o(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function l(t,e,n){return e&&s(t.prototype,e),n&&s(t,n),t}function h(){return parseInt((new window.Date).getTime()/1e3,10)}n.r(e),n.d(e,"getCurrentTime",function(){return h}),n.d(e,"getQueryParam",function(){return f}),n.d(e,"storageRead",function(){return p}),n.d(e,"storageWrite",function(){return m}),n.d(e,"Touchpoint",function(){return d}),n.d(e,"Channel",function(){return g}),n.d(e,"URLMatchingChannel",function(){return v}),n.d(e,"ReferrerMatchingChannel",function(){return y}),n.d(e,"SearchEngineChannel",function(){return w}),n.d(e,"AttributionItem",function(){return b}),n.d(e,"AttributionModel",function(){return k}),n.d(e,"LastTouchAttributionModel",function(){return O}),n.d(e,"AttributionEngine",function(){return P});var f=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=new RegExp("(^|&|\\?)".concat(t,"=(.*?)($|&)"),"ig").exec(e||window.location.search);return null!==n&&n.length>1?n[2]:null};function p(t){var e="",n=null;try{e=window.localStorage.getItem(t)}catch(t){}if(!e){var o=window.document.cookie.match(new RegExp("(^| )".concat(t,"=([^;]+)")));o&&o.length>1&&(e=o[2])}try{n=window.JSON.parse(e)}catch(t){}return n}function m(t,e){var n="";"string"!=typeof e&&(n=window.JSON.stringify(e));try{window.localStorage.setItem(t,n)}catch(e){window.document.cookie="".concat(t,"=").concat(n,";path=/;")}}var d=function(){function t(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h();c(this,t),this.channel=e,this.value=n,this.timestamp=o}return l(t,[{key:"getChannel",value:function(){return this.channel}},{key:"getValue",value:function(){return this.value}},{key:"getTimestamp",value:function(){return this.timestamp}},{key:"updateTimestamp",value:function(){this.timestamp=h()}},{key:"toJSON",value:function(){return{c:this.channel.getId(),v:this.value,t:this.timestamp}}}],[{key:"fromJSON",value:function(e,n){if(!n||void 0===n.c||void 0===n.t)throw new Error('Touchpoint.fromJSON: expected a string in form of {"c":"id","v":"value","t":1234567890}',n);var o=e.getChannelById(n.c);if(!o)throw new Error('Touchpoint.fromJSON: channel "'.concat(n.c,'" not found in provided engine'));return new t(o,n.v,n.t)}}]),t}(),g=function(){function t(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c(this,t),this.id=e,this.label=n,this.options=o,void 0===this.options.canOverwrite&&(this.options.canOverwrite=!1),void 0===this.options.isFirstViewOnly&&(this.options.isFirstViewOnly=!1)}return l(t,[{key:"getId",value:function(){return this.id}},{key:"getLabel",value:function(){return this.label}}]),t}(),v=function(t){function e(t,n,o,u,a){var s;return c(this,e),(s=i(this,r(e).call(this,t,n,a))).matchPattern=o,s.valueParamName=u,s}return u(e,g),l(e,[{key:"execute",value:function(){var t=null;if("string"==typeof this.matchPattern)t=null!==f(this.matchPattern);else if(this.matchPattern instanceof RegExp)t=window.location.search.match(this.matchPattern);else if("object"===o(this.matchPattern)){for(var e=Object.keys(this.matchPattern),n=[],i=0;i<e.length;i+=1){var r=this.matchPattern[e[i]],u=f(e[i]);n.push("boolean"==typeof r?!!u===r:u===r)}t=-1===n.indexOf(!1)}if(t){var a=null;return"string"==typeof this.valueParamName&&(a=decodeURIComponent(f(this.valueParamName))),new d(this,a)}return null}}]),e}(),y=function(t){function e(t,n,o,u){var a;return c(this,e),(a=i(this,r(e).call(this,t,n,u))).matchPattern=o,a}return u(e,g),l(e,[{key:"execute",value:function(){var t=this.matchPattern;if((this.matchPattern instanceof RegExp||"function"==typeof this.matchPattern)&&(t=[this.matchPattern]),t&&t.length>0)for(var e=0;e<t.length;e+=1)if(t[e]instanceof RegExp&&window.document.referrer.match(t[e])||"function"==typeof t[e]&&t[e](window.document.referrer))return new d(this);return null}}]),e}(),w=function(t){function e(){return c(this,e),i(this,r(e).apply(this,arguments))}return u(e,g),l(e,[{key:"execute",value:function(){for(var t=0;t<e.searchEngineRules.length;t+=1){var n=e.searchEngineRules[t];if(window.document.referrer.match(n.rule))return new d(this,n.valueParam?f(n.valueParam):"")}return null}}]),e}();w.searchEngineRules=[{rule:/(\.)?(google|googlesyndication|googleadservices|naver|bing|yahoo|yandex|daum|baidu|myway|ecosia|ask|dogpile|sogou|seznam|aolsvc|altavista|duckduckgo|mywebsearch|wow|webcrawler|infospace|blekko|docomo)(?=\.[a-z.]{2,5})/gi,valueParam:!1},{rule:/(\.)?(goo\.gl)/gi,valueParam:!1},{rule:/^android-app:\/\/com\.google\.android/gi,valueParam:!1}];var b=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;c(this,t),this.touchpoint=e,this.weight=n}return l(t,[{key:"getTouchpoint",value:function(){return this.touchpoint}},{key:"getWeight",value:function(){return this.weight}}]),t}(),k=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2592e3;c(this,t),this.touchpointLifetime=e}return l(t,[{key:"execute",value:function(){throw new Error("AttributionModel.execute must be implemented in overridden subclasses")}}]),t}(),O=function(t){function e(){return c(this,e),i(this,r(e).apply(this,arguments))}return u(e,k),l(e,[{key:"execute",value:function(){var t=this,e=null;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(function(n){n.getTimestamp()>h()-t.touchpointLifetime&&(null===e||n.getChannel().options.canOverwrite)&&(e=n)}),e?[new b(e,100)]:[]}}]),e}(),P=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1800,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"gktp";c(this,t),this.model=e,this.channelConfig=n,this.cookieName=i,this.visitDuration=o,this.touchpointHistory=[],this.lastTouchTimestamp=0;var r=p(this.cookieName);r&&this.restoreFromData(r)}return l(t,[{key:"execute",value:function(){for(var t=h(),e=null,n=0;n<this.channelConfig.length;n+=1){var o=this.channelConfig[n];if(e=o.execute()){var i=this.touchpointHistory.length>0?this.touchpointHistory[this.touchpointHistory.length-1]:null;o.options.isFirstViewOnly&&t-this.lastTouchTimestamp<this.visitDuration?e=null:i&&i.getValue()===e.getValue()&&i.getChannel().getId()===e.getChannel().getId()?i.updateTimestamp():this.touchpointHistory.push(e);break}}return this.lastTouchTimestamp=t,m(this.cookieName,this.saveToData()),e}},{key:"getAttributionItems",value:function(){return this.model.execute(this.getTouchpointHistory())}},{key:"getTouchpointHistory",value:function(){return this.touchpointHistory}},{key:"getChannelById",value:function(t){for(var e=0;e<this.channelConfig.length;e+=1)if(this.channelConfig[e].getId()===t)return this.channelConfig[e];return null}},{key:"restoreFromData",value:function(t){var e=this;t&&(this.lastTouchTimestamp=t.lt,this.touchpointHistory=[],t.e.forEach(function(t){var n=d.fromJSON(e,t);n&&e.touchpointHistory.push(n)}))}},{key:"saveToData",value:function(){return{e:this.touchpointHistory.map(function(t){return t.toJSON()}),lt:this.lastTouchTimestamp}}}]),t}()}])}); | ||
//# sourceMappingURL=marketing.umd.js.map |
{ | ||
"name": "marketing.js", | ||
"version": "0.0.3", | ||
"version": "0.0.6", | ||
"description": "A flexible marketingchannel recognition and attribution library for the browser", | ||
@@ -5,0 +5,0 @@ "author": "Rico Pfaus", |
@@ -9,2 +9,4 @@ # marketing.js | ||
## Usage | ||
### Installation | ||
Install the library from npm as usual. It has no external dependencies and should work in all modern browsers. | ||
@@ -31,6 +33,7 @@ | ||
Then we create the engine and pass our model and the marketing channel configuration. The channel configuration - when seen from a technical perspective - is quite simple and straightforward. It simply defines a set of rules that are executed sequentially to match against certain environment criteria. Nevertheless the entire business logic around marketing channels and attribution handling can be quite complex and requires a bit of background knowledge. | ||
### Configuration | ||
Create the engine and pass the model and the marketing channel configuration. The channel configuration - when seen from a technical perspective - is quite simple and straightforward. It simply defines a set of rules that are executed sequentially to match against certain environment criteria. Nevertheless the entire business logic around marketing channels and attribution handling can be quite complex and requires a bit of background knowledge. | ||
```javascript | ||
const engine = new AttributionEngine.init(model, [ | ||
const engine = new AttributionEngine(model, [ | ||
new SearchEngineChannel('seo', 'SEO'), | ||
@@ -41,3 +44,4 @@ new URLMatchingChannel('sea', 'SEA (Adwords)', 'adword', 'adword'), | ||
However, we are now set up to get the touchpoint for the current page impression ba calling the engine's `execute` method. This looks at URL, query string and referrer (depending on the types of channels in the configuration) and performs the channel recognition. It also adds the recognized `Touchpoint` to the internal list with the touchpoint history. | ||
### Execution | ||
Now everything is set up to get the touchpoint for the current page impression by calling the engine's `execute` method. This looks at URL, query string and referrer (depending on the types of channels in the configuration) and performs the channel recognition. It also adds the recognized `Touchpoint` to the internal list with the touchpoint history. | ||
@@ -49,3 +53,3 @@ ```javascript | ||
Finally, we can query the attributed `Touchpoint`(s) for the visitor based on our chosen `LastTouchAttributionModel` (looks at the single winning channel within the last 30 days). Note that this method returns an array of `AttributionItem` objects because we need to provide a `Touchpoint` and its associate `weight` on the attribution. Also we need any array here, as some attribution models may attribute multiple channels (e.g. "linear" or "time decay" models). | ||
Finally, we can query the attributed `Touchpoint`(s) for the visitor, based on our chosen `LastTouchAttributionModel` (looks at the single winning channel within the last 30 days). Note that this method returns an array of `AttributionItem` objects because we need to provide a `Touchpoint` and its associated `weight` on the attribution. Also we need an array here, as some attribution models may attribute multiple channels (e.g. "linear" or "time decay" models). | ||
@@ -66,2 +70,2 @@ ```javascript | ||
## API | ||
Check the code for inline JSDOC comments | ||
Coming soon, check the code for inline JSDOC comments until then ... |
@@ -434,9 +434,4 @@ /** | ||
const data = storageRead(this.cookieName); | ||
try { | ||
const json = JSON.parse(data); | ||
if (json) { | ||
this.restoreFromData(json); | ||
} | ||
} catch (e) { | ||
// ... | ||
if (data) { | ||
this.restoreFromData(data); | ||
} | ||
@@ -487,3 +482,3 @@ } | ||
// update data in storage | ||
storageWrite(this.cookieName, JSON.stringify(this.saveToData())); | ||
storageWrite(this.cookieName, this.saveToData()); | ||
@@ -490,0 +485,0 @@ return recognizedTouchpoint; |
Sorry, the diff of this file is not supported yet
67
65038
538