Created
April 7, 2018 15:47
-
-
Save chaffeqa/22068d9d7cff11cbaa12f0b76f9d3446 to your computer and use it in GitHub Desktop.
Adobe DTM events custom code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var id, mbatcher = /event/, val, events = [], linkTrackEvents = [], s_code = arguments[1], dataLayer = s_code.w._satellite.data.customVars.dataLayer || s_code.w._satellite.getVar('dataLayer'), log = s_code.w._satellite.Logger.echo; | |
for ( id in dataLayer){ | |
val = dataLayer[id] | |
if (mbatcher.test(id) && val) { | |
log('debug',"Event detected: " + id + '=' + val); | |
linkTrackEvents.push(id); | |
events.push(id); | |
} | |
} | |
s_code.events = events.join(','); | |
s_code.linkTrackEvents = linkTrackEvents.join(','); | |
if (events.length) s_code.linkTrackVars = 'events' + s_code.linkTrackVars; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment