Commit 30d90232 by Chris

Add: Support of GTM

parent 6f772644
......@@ -235,6 +235,9 @@ var Foresight = /** @class */ (function () {
if (this.options.sendEventFn !== null) {
return this.options.sendEventFn(data);
}
if (typeof window['gtm'] === 'function') {
return window['gtm'](__assign(__assign({ 'event': data.action, 'event_label': data.label, 'event_category': data.category, 'non_interaction': !data.interaction }, data.metrics), data.dimensions));
}
if (typeof window['gtag'] === 'function') {
return window['gtag']('event', data.action, __assign(__assign({ 'event_label': data.label, 'event_category': data.category, 'non_interaction': !data.interaction }, data.metrics), data.dimensions));
}
......
{
"name": "foresight",
"version": "0.1.0",
"version": "0.1.1",
"main": "dist/foresight.js",
"typings": "typings/foresight.d.ts",
"author": "James Ooi <wengteikooi@gmail.com>",
......
......@@ -191,6 +191,17 @@ class Foresight {
return this.options.sendEventFn(data);
}
if (typeof window['gtm'] === 'function') {
return window['gtm']({
'event': data.action,
'event_label': data.label,
'event_category': data.category,
'non_interaction': !data.interaction,
...data.metrics,
...data.dimensions
});
}
if (typeof window['gtag'] === 'function') {
return window['gtag']('event', data.action, {
'event_label': data.label,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment