Dassault Logo
// PAGE-LEVEL CONSTANTS; var CATEGORY = 'events'; var ENV = 'PRD'; var SITE_NAME = '3dexperience_forum_nam'; var SUB_CATEGORY = '3dexperience_forum_nam'; var TAG_COMMANDER_SCRIPT_ID = 'tag-commander-script'; var TYPE = 'contact'; // ANALYTICS/TIMING UTIL METHODS /** * options: { * enableLogs: Boolean, * intervalFrequency: Number, * logIdentifier: String, * maxIterations: Number, * onSuccess: () => void, * successCheck: () => Boolean, * } */ function waitForX(options) { var log = function log() { if (options.enableLogs) console.log.apply(console, arguments); }; var logSuffix = options.logIdentifier ? ' -- [' + options.logIdentifier + ']' : ''; var intervalFrequency = options.intervalFrequency || 100; var maxIterations = options.maxIterations || 100; // Do 1 immediate check before the interval starts. if (options.successCheck()) { log('SUCCESS (immediate), no interval needed' + logSuffix); options.onSuccess(); return; } log('every ' + intervalFrequency + 'ms, for ' + intervalFrequency * maxIterations + 'ms' + logSuffix); var iterations = 0; var waitTimer = window.setInterval(function () { if (options.successCheck.apply(options)) { log('SUCCESS, waited: ' + ((iterations + 1) * intervalFrequency) + 'ms (' + (iterations + 1) + ' iterations)' + logSuffix); options.onSuccess.apply(options); window.clearInterval(waitTimer); log('cleared interval' + logSuffix); } if (iterations >= maxIterations) { log('TIMED OUT' + logSuffix); // Safety net to ensure this interval won't run forever. window.clearInterval(waitTimer); log('cleared interval' + logSuffix); } iterations++; }, options.intervalFrequency); } function createMetaTagWithAttributes(attributes) { var meta = document.createElement('meta'); Object.keys(attributes).forEach(function (key) { meta.setAttribute(key, attributes[key]); }); return meta; } function injectPageMeta(attributes) { var meta = createMetaTagWithAttributes(attributes); document.head.appendChild(meta); } function setupAnalyticsListener(el, attributesList) { el.setAttribute('itemscope', true); el.setAttribute('itemtype', 'http://tracking.3ds.com/ClickAction'); attributesList.forEach(function (attributes) { var meta = createMetaTagWithAttributes(attributes); el.appendChild(meta); }); } function triggerAnalyticsPageView(pageName) { if (!document.querySelector('#' + TAG_COMMANDER_SCRIPT_ID)) { injectPageMeta({ property: 'tk:name', content: pageName }); injectTagCommanderScript(); } else if (window.ds_event) { window.ds_event('this', 'page', { event : 'page', page_category: CATEGORY, page_name: pageName, page_sub_category: SUB_CATEGORY, page_type: TYPE }); } else { console.warn('Unable to trigger analytics page view'); } } function injectTagCommanderScript() { var tagCommanderScript = document.createElement('script'); tagCommanderScript.type = 'text/javascript'; tagCommanderScript.src = '//tracking.3ds.com/stat/init/ds_init_global.js'; tagCommanderScript.id = TAG_COMMANDER_SCRIPT_ID; document.head.appendChild(tagCommanderScript); } // ONE-TIME PAGE EXECUTION document.querySelector('html').setAttribute('xmlns:tk', 'http://tracking.3ds.com/ns#'); injectPageMeta({ property: 'td:env', content: ENV }); injectPageMeta({ property: 'tk:site_name', content: SITE_NAME }); injectPageMeta({ property: 'tk:category', content: CATEGORY }); injectPageMeta({ property: 'tk:sub_category', content: SUB_CATEGORY }); injectPageMeta({ property: 'tk:type', content: TYPE }); waitForX({ intervalFrequency: 100, maxIterations: 150, onSuccess: function () { var leftNavLinks = document.querySelectorAll('.rfwf-nav-container ul a'); // CUSTOM SUPPORT button setupAnalyticsListener(leftNavLinks[0], [ { itemprop: 'category', content: 'navigation' }, { itemprop: 'action', content: 'menu' }, { itemprop: 'label', content: 'email_customer_support' } ]) // WEBSITE LINK button setupAnalyticsListener(leftNavLinks[1], [ { itemprop: 'category', content: 'navigation' }, { itemprop: 'action', content: 'menu' }, { itemprop: 'label', content: '3dexperience_forum_nam' } ]) }, successCheck: function () { var leftNavLinks = document.querySelectorAll('.rfwf-nav-container ul a'); return leftNavLinks && leftNavLinks.length && leftNavLinks.length > 1; }, })
// v3 if (data.page === 'login') { triggerAnalyticsPageView('/3ds/events/3dexperience_forum_nam/registration/' + data.page); waitForX({ intervalFrequency: 100, maxIterations: 150, onSuccess: function () { var createAccountButton = document.querySelector('.create-account-frame button'); setupAnalyticsListener(createAccountButton, [ { itemprop: 'category', content: 'CTA' }, { itemprop: 'action', content: 'middle' }, { itemprop: 'label', content: 'create_account' } ]); }, successCheck: function () { return document.querySelector('.create-account-frame button'); }, }); } if (data.page === 'createaccount') { triggerAnalyticsPageView('/3ds/events/3dexperience_forum_nam/registration/' + data.page); waitForX({ intervalFrequency: 100, maxIterations: 150, onSuccess: function () { var continueButton = document.querySelector('#wf-btn-submit'); setupAnalyticsListener(continueButton, [ { itemprop: 'category', content: 'CTA' }, { itemprop: 'action', content: 'form' }, { itemprop: 'label', content: '/3ds/events/3dexperience_forum_nam/registration/form/firststep' } ]); }, successCheck: function () { return document.querySelector('#wf-btn-submit'); }, }); } if (data.page === 'firststep') { triggerAnalyticsPageView('/3ds/events/3dexperience_forum_nam/events/registration/' + data.page); waitForX({ intervalFrequency: 100, maxIterations: 150, onSuccess: function () { var continueButton = document.querySelector('#wf-btn-submit'); setupAnalyticsListener(continueButton, [ { itemprop: 'category', content: 'CTA' }, { itemprop: 'action', content: 'form' }, { itemprop: 'label', content: '/3ds/events/3dexperience_forum_nam/registration/form/generalattendee' } ]); var cancelButton = document.querySelector('#wf-btn-cancel'); setupAnalyticsListener(cancelButton, [ { itemprop: 'category', content: 'navigation' }, { itemprop: 'action', content: 'middle' }, { itemprop: 'label', content: 'cancel' } ]); }, successCheck: function () { return ( document.querySelector('#wf-btn-submit') && document.querySelector('#wf-btn-cancel') ); }, }); } if ( data.page === 'generalattendee' || data.page === 'media' || data.page === 'employee' ) { triggerAnalyticsPageView('/3ds/events/3dexperience_forum_nam/registration/' + data.page); waitForX({ intervalFrequency: 100, maxIterations: 150, onSuccess: function () { var continueButton = document.querySelector('#wf-btn-submit'); setupAnalyticsListener(continueButton, [ { itemprop: 'category', content: 'CTA' }, { itemprop: 'action', content: 'form' }, { itemprop: 'label', content: '/3ds/events/3dexperience_forum_nam/registration/form/submit' } ]); var cancelButton = document.querySelector('#wf-btn-cancel'); setupAnalyticsListener(cancelButton, [ { itemprop: 'category', content: 'navigation' }, { itemprop: 'action', content: 'middle' }, { itemprop: 'label', content: 'cancel' } ]); }, successCheck: function () { return ( document.querySelector('#wf-btn-submit') && document.querySelector('#wf-btn-cancel') ); }, }); } if (data.page === 'order') { triggerAnalyticsPageView('/3ds/events/3dexperience_forum_nam/registration/' + data.page); waitForX({ intervalFrequency: 100, maxIterations: 150, onSuccess: function () { var orderButtons = document.querySelectorAll('.rfwf-orders-buttons button'); // BACK button setupAnalyticsListener(orderButtons[0], [ { itemprop: 'category', content: 'navigation' }, { itemprop: 'action', content: 'middle' }, { itemprop: 'label', content: 'back' } ]); // CLEAR ORDER button setupAnalyticsListener(orderButtons[1], [ { itemprop: 'category', content: 'navigation' }, { itemprop: 'action', content: 'middle' }, { itemprop: 'label', content: 'clear_order' } ]); // SUBMIT button setupAnalyticsListener(orderButtons[2], [ { itemprop: 'category', content: 'CTA' }, { itemprop: 'action', content: 'form' }, { itemprop: 'label', content: '/3ds/events/3dexperience_forum_nam/registration/form/submit' } ]); }, successCheck: function () { var orderButtons = document.querySelectorAll('.rfwf-orders-buttons button'); return orderButtons && orderButtons.length && orderButtons.length > 2; }, }); } if (data.page === 'confirmation') { triggerAnalyticsPageView('/3ds/events/3dexperience_forum_nam/registration/thankyou'); waitForX({ intervalFrequency: 100, maxIterations: 150, onSuccess: function () { var confirmationButtons = document.querySelectorAll('.rfwf-confirmation-buttons button'); // CONTINUE button setupAnalyticsListener(confirmationButtons[0], [ { itemprop: 'category', content: 'navigation' }, { itemprop: 'action', content: 'middle' }, { itemprop: 'label', content: 'continue' } ]); // PRINT button setupAnalyticsListener(confirmationButtons[1], [ { itemprop: 'category', content: 'navigation' }, { itemprop: 'action', content: 'middle' }, { itemprop: 'label', content: 'print' } ]); }, successCheck: function () { var confirmationButtons = document.querySelectorAll('.rfwf-confirmation-buttons button'); return confirmationButtons && confirmationButtons.length && confirmationButtons.length > 1; }, }); } if (data.page === 'agenda') { triggerAnalyticsPageView('/3ds/events/3dexperience_forum_nam/registration/' + data.page); }