gtmeventtracking
Version:
GTM Google event Tracking Management System
84 lines (79 loc) • 2.95 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('angulartics2')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'angulartics2'], factory) :
(factory((global.angulartics2 = global.angulartics2 || {}, global.angulartics2.segment = {}),global.ng.core,global.angulartics2));
}(this, (function (exports,core,angulartics2) { 'use strict';
var Angulartics2Segment = (function () {
function Angulartics2Segment(angulartics2$$1) {
var _this = this;
this.angulartics2 = angulartics2$$1;
this.angulartics2.pageTrack
.pipe(this.angulartics2.filterDeveloperMode())
.subscribe(function (x) { return _this.pageTrack(x.path); });
this.angulartics2.eventTrack
.pipe(this.angulartics2.filterDeveloperMode())
.subscribe(function (x) { return _this.eventTrack(x.action, x.properties); });
this.angulartics2.setUserProperties
.subscribe(function (x) { return _this.setUserProperties(x); });
this.angulartics2.setUserPropertiesOnce
.subscribe(function (x) { return _this.setUserProperties(x); });
this.angulartics2.setAlias
.subscribe(function (x) { return _this.setAlias(x); });
}
Angulartics2Segment.prototype.pageTrack = function (path) {
try {
analytics.page(path);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Segment.prototype.eventTrack = function (action, properties) {
try {
analytics.track(action, properties);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Segment.prototype.setUserProperties = function (properties) {
try {
if (properties.userId) {
analytics.identify(properties.userId, properties);
}
else {
analytics.identify(properties);
}
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Segment.prototype.setAlias = function (alias) {
try {
analytics.alias(alias);
}
catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
};
Angulartics2Segment.decorators = [
{ type: core.Injectable },
];
Angulartics2Segment.ctorParameters = function () { return [
{ type: angulartics2.Angulartics2, },
]; };
return Angulartics2Segment;
}());
exports.Angulartics2Segment = Angulartics2Segment;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=segment.umd.js.map