import { createDataLayerDefaultNavObject } from "../../data-layer-utils" import { DataManager, updateDataLayerOnEvent } from "../../main" const defaultVideoTitle = (input_text: string) => { /* Currently used for a hard coded value. Need to look into a more reliable way to get dynamically grab this. */ let output_text = input_text if(input_text == "" || input_text == null) { if(window.location.href.endsWith('/cja')){ output_text = 'Analytics Spotlight - Adobe CJA' } } return output_text } const defaultVideoNavContext = (input_text: string) => { /* Currently used for a hard coded value. Need to look into a more reliable way to get dynamically grab this. */ let output_text = input_text if(input_text == "" || input_text == null) { if(window.location.href.endsWith('/cja')){ output_text = 'Watch CJA Video' } } return output_text } // Open Video const attachVideoButtonClick = () => { $('.video-block').on('click', function() { const navObj = createDataLayerDefaultNavObject('hero', defaultVideoNavContext(""), 1, '') updateDataLayerOnEvent({...DataManager.getCurrentPageData(), ...navObj}); }) } // Play Video const attachVideoStart = () => { $('body > section:nth-child(4) > div.w-layout-blockcontainer.container-167.w-container > div > div.video-block > a').on('click', function() { const navObj = { event: 'videoEvent', eventCategory: 'video', eventAction: 'videoPlay', videoTitle: defaultVideoTitle("") } updateDataLayerOnEvent({...DataManager.getCurrentPageData(), ...navObj}); }) } export const attachVideoEvents = () => { attachVideoButtonClick(); //attachVideoPlayButtonClick(); attachVideoStart(); }