TagManager
Init (ES6)
import TagManager from 'tagmanager-wrap';
const tagmanager = new TagManager(window.tagManagerDataLayer, {
gtmId: 'AAABBB000',
startPush: {
page_type: 'page:price',
path_category: 'category/sub-category',
experiments: window.experiments || [],
},
});
tagManager.init();
tagManager.bindEvents();
Init (Global)
var tagManager = new window.tagmanagerWrap.default(window.tagManagerDataLayer, {
gtmId: 'AAABBB000',
startPush: {
page_type: "pages:home",
path_category: "category/sub-category",
experiments: window.experiments || []
}
});
Init (CommonJs)
var TagManager = require('tagmanager-wrap');
var tagManager = new TagManager.default(window.tagManagerDataLayer, {
gtmId: 'AAABBB000',
startPush: {
page_type: "pages:home",
path_category: "category/sub-category",
experiments: window.experiments || []
}
});
Init (AMD)
define(['tagmanager-wrap'], function(TagManager){
var tagManager = new TagManager(window.tagManagerDataLayer, {
gtmId: 'AAABBB000',
startPush: {
page_type: "pages:home",
path_category: "category/sub-category",
experiments: window.experiments || []
}
});
});
eventCategory
var btnEventCategory = document.getElementsByClassName('eventCategory')[0];
btnEventCategory.addEventListener('click', function () {
tagManager.eventCategory("pre-fill", {
eventAction: "success"
});
console.log(tagManager);
});
prependExperiment
var btnPrependExperiment = document.getElementsByClassName('prependExperiment')[0];
btnPrependExperiment.addEventListener('click', function () {
tagManager.prependExperiment({
event: 'yourCustomEvent',
schema: 'your:br.com.custom/schema/jsonschema/1-0-0',
data: {
experimentDescription: 'Custom Description',
experimentGoal: 'request conversion rate',
experimentId: 'popup-user-leaves-request',
experimentPageCategory: ['all'],
experimentPageType: ['categories'],
experimentTool: 'Abba',
experimentType: 'page',
experimentVersion: 'demo',
},
});
console.log(tagManager);
});
virtualPageView
var btnVirtualPageView = document.getElementsByClassName('virtualPageView')[0];
btnVirtualPageView.addEventListener('click', function () {
tagManager.virtualPageView('/profile/created');
console.log(tagManager);
});
custom Obj
var btnCustomObj = document.getElementsByClassName('customObj')[0];
btnCustomObj.addEventListener('click', function () {
tagManager.custom({
user_id: 123,
event: 'user_info'
});
console.log(tagManager);
});