Journey JS OP Custom Tag
Overview
This custom tag reports whether or not the expected HTML is on the page and if the Journey JS snippet was initialized successfully.
- htmlFound: Reports true if the Journey JS script tag was found on the page, otherwise false
- jsFound: Reports true if the Journey JS was successfully initialized, otherwise false
Custom Tag
function opReqGetAsync(paramObject, acct, callback) { var baseURL = window.location.protocol+"//"+window.location.hostname+"/observepointcustomtag?acct=" + acct; var opReq = new XMLHttpRequest(); opReq.onreadystatechange = function() { if (opReq.readyState === 4 && opReq.status === 200) { callback(opReq.responseText); } } opReq.open("POST", baseURL, true); opReq.send(JSON.stringify(paramObject)); } var obj = {}; let htmlExists = false; let jsExists = false; if(journey.Config != undefined) { jsExists = true; } let html = [...document.querySelectorAll('script')].filter(s => { return s.outerHTML.includes('journey.initialize(options,journey.load)') }); if(html.length > 0) { htmlExists = true; } obj['htmlFound'] = htmlExists; obj['jsFound'] = jsExists; opReqGetAsync(obj, 'Journey JS');