Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag update #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
Exponea Initialisation, Event Tracking, Customer Identification and Upading of Customer Attributes.
# Bloomreach Engagement Tag for Google Tag Manager Web Container

We are providing the templates for technically advanced customers who understand the underlying code of the templates and are able to modify the template according to their needs.
Bloomreach does not currently provide production-level support for any kind of usage of this template.


## Useful links

- https://documentation.bloomreach.com/engagement/docs/integration
- https://documentation.bloomreach.com/engagement/docs/web-tracking
- https://documentation.bloomreach.com/engagement/docs/implementing-exponea-via-google-tag-manager
- https://documentation.bloomreach.com/engagement/docs/1st-party-cookie-tracking-solutions#2-google-tag-manager-server-side-solution


## Open Source

Bloomreach Engagement Tag for GTM is developed and maintained by [Bloomreach Team](https://www.bloomreach.com/) and [Stape Team](https://stape.io/) under the Apache 2.0 license.
5 changes: 4 additions & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
homepage: "https://exponea.com/"
documentation: "https://github.com/exponea/gtm_view_category/blob/master/README.md"
versions:
- sha: 8b03dd0a8006d0fc440717e86183b0f7d1eded61
changeNotes: Fix custom event tracking.
- sha: 4275b1c33ad253f376f7dddb8af8ba5914bb7fad
changeNotes: Add sGTM support.
- sha: f118270d6a9989ee532deda06108122bfeebe32c
changeNotes: Release of Exponea Tag.
- sha: 9d33d33618de2a42907a7958a4393ecb86af4924
changeNotes: Initial release.

56 changes: 56 additions & 0 deletions template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const makeTableMap = require('makeTableMap');
const callInWindow = require('callInWindow');
const injectScript = require('injectScript');
const copyFromWindow = require('copyFromWindow');
const setInWindow = require('setInWindow');

const jsUrl = data.isServerUsed ? data.jsURL : 'https://api.exponea.com/js/exponea.min.js';

if (data.projectToken) injectScript(jsUrl, initializeExponea, data.gtmOnFailure, jsUrl);
else exponeaFunctions();

function exponeaFunctions() {
if (data.eventTrackingRadio === 'standardEvent' && data.standardEventList !== 'noneSelected') {
callInWindow('exponea.track', data.standardEventList, arrayToObject(data.standardEventProperties));
} else if (data.eventTrackingRadio === 'customEvent') {
callInWindow('exponea.track', data.customEventName, arrayToObject(data.customEventProperties));
} else if (data.eventTrackingRadio === 'eeEvent') {
callInWindow('exponea.trackEnhancedEcommerce', data.eeObj, data.eeKind);
}

if (data.updateCustomerAttributes) {
callInWindow('exponea.update', arrayToObject(data.updateCustomerAttributes));
}

if (data.identifyCustomer) {
callInWindow('exponea.identify', arrayToObject(data.identifyCustomer));
}
}

function arrayToObject(arrayOfObjects) {
return makeTableMap(arrayOfObjects, 'attributeName', 'attributeValue');
}

function initializeExponea() {
let exponeaIsInitialized = copyFromWindow('exponeaIsInitialized');

if (!exponeaIsInitialized) {
setInWindow('exponeaIsInitialized', true, true);

callInWindow('exponea.initialize', {
"token": data.projectToken,
"target": data.targetAPI,
"ping": {
"enabled": data.trackSession
},
"track": {
"visits": data.trackPageVisit,
"google_analytics": data.trackGACookie
}
});
}

exponeaFunctions();
}

data.gtmOnSuccess();
188 changes: 136 additions & 52 deletions template.tpl

Large diffs are not rendered by default.