Setup TrackJS and GTM in Dashboard

pull/14693/head
jesusbotella 6 years ago
parent f6983e6da9
commit c0b1a0c4b6

@ -0,0 +1,34 @@
import { TrackJS } from 'trackjs';
import store from '../store';
// TrackJS Configuration
const isTrackJSEnabled = store.state.config.trackjs_enabled;
if (isTrackJSEnabled) {
TrackJS.install({
token: store.state.config.trackjs_customer,
application: store.state.config.trackjs_app_key,
userId: store.state.user.username,
version: __ASSETS_VERSION__ // eslint-disable-line
});
}
// Google Tag Manager
const tagManagerId = store.state.config.google_tag_manager_id;
if (tagManagerId) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
userId: store.state.user.id,
userAccountType: store.state.user.account_type,
userSignUpDate: Date.parse(store.state.user.created_at) / 1000
});
/* eslint-disable */
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer', store.state.config.google_tag_manager_id);
/* eslint-enable */
}

@ -1,9 +1,11 @@
import Vue from 'vue';
import VueModal from 'vue-js-modal';
import i18n from './i18n';
import store from './store';
import router from './router';
import './directives';
import './core/trackers';
import App from './App';

@ -51,6 +51,7 @@
"rangeslider.js": "2.3.0",
"tinycolor2": "^1.4.1",
"torque.js": "CartoDB/torque#master",
"trackjs": "^3.1.2",
"underscore": "1.8.3",
"urijs": "^1.19.0",
"url-parse": "^1.4.0",

@ -36,7 +36,8 @@ module.exports = {
new webpack.DefinePlugin({
__IN_DEV__: JSON.stringify(false),
__ENV__: JSON.stringify('prod')
__ENV__: JSON.stringify('prod'),
__ASSETS_VERSION__: JSON.stringify(version)
}),
new MiniCssExtractPlugin({

Loading…
Cancel
Save