1/** 2 * In this file: 3 * - datalayer 4 */ 5 6let userId = user_data.userId; 7 8/******************************************************************************************************* 9 * DATALAYER 10 *******************************************************************************************************/ 11jQuery(document).ready(function($){ 12 13 14 /*============================================================================ 15 FUNCTIONS 16 ============================================================================*/ 17 18 /*------------------------------------------------------ 19 GET CTA LOCATION 20 ------------------------------------------------------*/ 21 if (typeof dataLayer === "undefined") { 22 dataLayer = []; 23 } 24 if (typeof window.gtag === "undefined") { 25 window.gtag = function(){ 26 dataLayer.push(arguments); 27 } 28 window.gtag('js', new Date()); 29 window.gtag('config', 'GTM-MQCTMBN'); 30 } 31 32 function get_cta_locaion(cta) { 33 let location_data = { 34 'label': 'Body', 35 'type': null, 36 'index': null, 37 }; 38 39 // Check if cta in header or footer 40 let header = $('header').get(0); 41 let footer = $('footer').get(0); 42 let element = cta.get(0); 43 if( $.contains(header, element) ) { 44 location_data.label = 'Header'; 45 } else if ( $.contains(footer, element) ) { 46 location_data.label = 'Footer'; 47 } 48 49 // check if cta in location type section 50 let type_section = cta.closest('section'); 51 if( type_section.length > 0 ) { 52 location_data.type = 'section'; 53 location_data.index = type_section.index(); 54 } 55 56 return location_data; 57 } 58 59 /*------------------------------------------------------*/ 60 61 /*============================================================================*/ 62 63 64 /*------------------------------------------------------ 65 PUSH DATALAYER ON PAGE VIEW 66 ------------------------------------------------------*/ 67 let userID = null; 68 let loggedIn = userId ? 'yes' : 'no'; 69 dataLayer.push({ 70 'event': 'GTM page to GA', 71 'pageURL': window.location.href, 72 'pageSection': 'website', 73 'userID': userId, 74 'isLoggedIn': loggedIn, 75 }); 76 77 /*------------------------------------------------------*/ 78 79 /*------------------------------------------------------ 80 PUSH DATALAYER ON TRY FREE CLICK 81 ------------------------------------------------------*/ 82 $('.try-free').click(function () { 83 let button = $(this); 84 let buttonText = button.text().trim(); 85 let location_data = get_cta_locaion(button); 86 87 dataLayer.push({ 88 'event': 'GTM event to GA', 89 'GA_event_category': 'website', 90 'GA_event_action': 'try it for free clicked', 91 'GA_event_label': location_data.label, 92 'content': buttonText, 93 'location_type': location_data.type, 94 'location_index': location_data.index, 95 }); 96 }); 97 98 /*------------------------------------------------------*/ 99 100 101 /*------------------------------------------------------ 102 PUSH DATALAYER ON PRICING PLAN PICKED 103 ------------------------------------------------------*/ 104 if(window.location.pathname == '/pricing') { 105 $('.pricing-plan').click(function () { 106 let planName = $(this).attr('name'); 107 let planId = $(this).attr('id'); 108 109 dataLayer.push({ 110 'event': 'GTM event to GA', 111 'GA_event_category': 'website', 112 'GA_event_action': planName, 113 'GA_event_label': planId, 114 'content': 'na', 115 }); 116 }); 117 118 /*------------------------------------------------------*/ 119 /* PURCHASE EVENTS */ 120 /* selected yearly plan from pricing toggle */ 121 $('.pricing-annual-button').click(function () { 122 dataLayer.push({ 123 'event': 'pricing plan toggled', 124 'ga4_object': 'PRICING', 125 'ga4_action': 'TOGGLED', 126 'ga4_dimensions': { 127 'pricingToggle': 'yearly', 128 }, 129 }); 130 }); 131 132 /* select monthly plan from pricing toggle */ 133 $('.pricing-monthly-button').click(function () { 134 dataLayer.push({ 135 'event': 'pricing plan toggled', 136 'ga4_object': 'PRICING', 137 'ga4_action': 'TOGGLED', 138 'ga4_dimensions': { 139 'pricingToggle': 'monthly', 140 }, 141 }); 142 }); 143 144 /* clicked on pricing plan to begin purchase flow */ 145 $('.plan-item .pricing-plan').click(function () { 146 let packageLevel = $(this).attr('name'); 147 let pricingView = $('.pricing-radio-buttons.active').hasClass('pricing-annual-button') ? 'yearly' : 'monthly'; 148 dataLayer.push({ 149 'event': 'purchase flow begin', 150 'ga4_object': 'PURCHASE', 151 'ga4_action': 'BEGIN', 152 'ga4_dimensions': { 153 'purchaseStep': 'step1', 154 'packageLevel': packageLevel, 155 'pricingView': pricingView, 156 'purchaseType': 'new' 157 } 158 }); 159 }); 160 } 161 /* END PURCHASE EVENTS */ 162 163 164 /* CTA EVENTS */ 165 /* clicked on cta button */ 166 $('.cta-button').click(function () { 167 let text = $(this).text(); 168 dataLayer.push({ 169 'event': 'cta clicked', 170 'ga4_object': 'CTA', 171 'ga4_action': 'CLICKED', 172 'ga4_dimensions': { 173 'text': text, 174 } 175 }); 176 }); 177 /* END CTA EVENTS */ 178 179 /* MISC EVENTS */ 180 $('.leads-reports .industry li a').click(function () { 181 let text = $(this).text(); 182 dataLayer.push({ 183 'event': 'leads reports clicked',
184 'ga4_object': 'LEADSREPORTS', 185 'ga4_action': 'CLICKED', 186 'ga4_dimensions': { 187 'text': text, 188 } 189 }); 190 }); 191 $('.leads-reports .cta-button').click(function () { 192 let text = $(this).text(); 193 dataLayer.push({ 194 'event': 'leads reports clicked', 195 'ga4_object': 'LEADSREPORTS', 196 'ga4_action': 'CLICKED', 197 'ga4_dimensions': { 198 'text': text, 199 } 200 }); 201 }); 202 203 $('.leads-reports .market-share li a').click(function () { 204 let text = $(this).text(); 205 dataLayer.push({ 206 'event': 'leads reports clicked', 207 'ga4_object': 'LEADSREPORTS', 208 'ga4_action': 'CLICKED', 209 'ga4_dimensions': { 210 'text': text, 211 } 212 }); 213 }); 214 215 $('.accordion-list .question').click(function () { 216 let faqTitle = $(this).find('h5').text(); 217 dataLayer.push({ 218 'event': 'FAQ expanded/closed', 219 'ga4_object': 'FAQ', 220 'ga4_action': 'EXPANDED/CLOSED', 221 'ga4_dimensions': { 222 'faqTitle': faqTitle, 223 } 224 }); 225 }); 226 /* END MISC EVENTS */ 227 228 229 /* INITIAL NAVIGATION */ 230 $('.main-nav-link').click(function () { 231 let text = $(this).text(); 232 dataLayer.push({ 233 'event': 'navigation clicked', 234 'ga4_object': 'NAVIGATION', 235 'ga4_action': 'CLICKED', 236 'ga4_dimensions': { 237 'navigationText': text, 238 } 239 }); 240 }); 241 /* END INITIAL NAVIGATION */ 242 243 244 /*------------------------------------------------------*/ 245 246}); 247/*******************************************************************************************************/ 248
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.