1jQuery(document).ready(function($) { 2 $('.email-share').on('click', function(e) { 3 try { 4 window.dataLayer = window.dataLayer || []; 5 window.dataLayer.push({ 6 'event': 'social_share', 7 'share_option': 'email' 8 }); 9 } catch (error) { 10 console.error('Error tracking email share:', error); 11 } 12 }); 13 14 $('.copy-link').on('click', function(e) { 15 try { 16 window.dataLayer = window.dataLayer || []; 17 window.dataLayer.push({ 18 'event': 'social_share', 19 'share_option': 'copy_link' 20 }); 21 } catch (error) { 22 console.error('Error tracking copy link:', error); 23 } 24 }); 25 26 $('.facebook-share').on('click', function(e) { 27 try { 28 window.dataLayer = window.dataLayer || []; 29 window.dataLayer.push({ 30 'event': 'social_share', 31 'share_option': 'facebook' 32 }); 33 } catch (error) { 34 console.error('Error tracking Facebook share:', error); 35 } 36 }); 37 38 $('.linked-share').on('click', function(e) { 39 try { 40 window.dataLayer = window.dataLayer || []; 41 window.dataLayer.push({ 42 'event': 'social_share', 43 'share_option': 'linkedin' 44 }); 45 } catch (error) { 46 console.error('Error tracking LinkedIn share:', error); 47 } 48 }); 49 50 $('.x-share').on('click', function(e) { 51 try { 52 window.dataLayer = window.dataLayer || []; 53 window.dataLayer.push({ 54 'event': 'social_share', 55 'share_option': 'x' // formerly known as Twitter 56 }); 57 } catch (error) { 58 console.error('Error tracking X share:', error); 59 } 60 }); 61 62 $('.job-apply').on('click', function(e) { 63 try { 64 window.dataLayer = window.dataLayer || []; 65 window.dataLayer.push({ 66 'event': 'jobs_apply_now_clicks', 67 }); 68 } catch (error) { 69 console.error('Error tracking job apply:', error); 70 } 71 }); 72 73 $('.event-book-online').on('click', function(e) { 74 try { 75 window.dataLayer = window.dataLayer || []; 76 window.dataLayer.push({ 77 'event': 'events_book_online_clicks', 78 }); 79 } catch (error) { 80 console.error('Error tracking event book online:', error); 81 } 82 }); 83 $('.cta_button.book-training').on('click', function(e) { 84 try { 85 window.dataLayer = window.dataLayer || []; 86 window.dataLayer.push({ 87 'event': 'training_book_online_clicks', 88 }); 89 } catch (error) { 90 console.error('Error tracking event book online:', error); 91 } 92 }); 93 94 $('.button.custom-btn.trustlaw-login').on('click', function(e) { 95 try { 96 window.dataLayer = window.dataLayer || []; 97 window.dataLayer.push({ 98 'event': 'trustlaw_join_clicks', 99 'cta_text': 'login', // the anchor text of the button's link e.g. join_trustlaw, login, sign_up_now 100 }); 101 } catch (error) { 102 console.error('Error tracking TrustLaw Login:', error); 103 } 104 }); 105 $('.button.custom-btn.trustlaw-signup').on('click', function(e) { 106 try { 107 window.dataLayer = window.dataLayer || []; 108 window.dataLayer.push({ 109 'event': 'trustlaw_join_clicks', 110 'cta_text': 'join_trustlaw', // the anchor text of the button's link e.g. join_trustlaw, login, sign_up_now 111 }); 112 } catch (error) { 113 console.error('Error tracking TrustLaw Signup:', error); 114 } 115 }); 116 117 $('.jump-link.trust-conference-register, .button.custom-btn.trustconference-register').on('click', function(e) { 118 try { 119 window.dataLayer = window.dataLayer || []; 120 window.dataLayer.push({ 121 'event': 'trust_conference_register_clicks', 122 }); 123 } catch (error) { 124 console.error('Error tracking Trust Conference Register:', error); 125 } 126 }); 127 128 // $('#sg_FormFor7952946 input[type=submit]').on('click', function(e) { 129 // // Prevent the default form submission 130 // e.preventDefault(); 131 // console.log('Newsletter Sub'); 132 // try { 133 // window.dataLayer = window.dataLayer || []; 134 // window.dataLayer.push({ 135 // 'event': 'custom_form_submit', 136 // 'form_name': 'newsletter', 137 // }); 138 139 // // Log success or delay the form submission to allow event pushing to complete 140 // console.log('Data layer event pushed successfully.'); 141 142 // } catch (error) { 143 // console.error('Error tracking Newsletter:', error); 144 // } 145 146 // // Delay the form submission by a short amount (e.g., 300ms) 147 // setTimeout(function() { 148 // // Trigger form submission manually 149 // $('#sg_FormFor7952946').submit(); 150 // }, 300); // Adjust the timeout as needed 151 // });
152 const urlParams = new URLSearchParams(window.location.search); 153 const sgTarget = urlParams.get('__sgtarget'); 154 155 if (window.location.hash === '#sgbody-7952946' && sgTarget === '-1') { 156 // Get the hash part of the URL 157 const urlHash = window.location.hash; 158 159 // Get the query parameters from the URL 160 const urlParams = new URLSearchParams(window.location.search); 161 const sgTarget = urlParams.get('__sgtarget'); 162 163 // Check if the hash is #sgbody-7952946 and the __sgtarget parameter is -1 164 if (urlHash === '#sgbody-7952946' && sgTarget === '-1') { 165 // console.log('Tracking newsletter event on page load'); 166 167 try { 168 window.dataLayer = window.dataLayer || []; 169 window.dataLayer.push({ 170 'event': 'custom_form_submit', 171 'form_name': 'newsletter', 172 }); 173 console.log('Data layer event pushed successfully.'); 174 } catch (error) { 175 console.error('Error tracking Newsletter:', error); 176 } 177 } else { 178 console.log('Conditions not met for tracking.'); 179 } 180 } 181 182 183 $('#gform_1 input[type=submit]').on('click', function(e) { 184 try { 185 window.dataLayer = window.dataLayer || []; 186 window.dataLayer.push({ 187 'event': 'custom_form_submit', 188 'form_name': 'contact', 189 }); 190 } catch (error) { 191 console.error('Error tracking contact form:', error); 192 } 193 }); 194 $('#gform_4 input[type=submit]').on('click', function(e) { 195 try { 196 window.dataLayer = window.dataLayer || []; 197 window.dataLayer.push({ 198 'event': 'custom_form_submit', 199 'form_name': 'book_training', 200 }); 201 } catch (error) { 202 console.error('Error tracking book_training:', error); 203 } 204 }); 205 $('#gform_6 input[type=submit]').on('click', function(e) { 206 try { 207 // Get the current URL 208 var url = window.location.href; 209 210 // Use regex to extract the trailing path, handling both single and multi-segment paths 211 var trailingPath = url.match(/\/([^\/]+\/?[^\/]*)\/?$/); 212 var formattedPath = ''; 213 214 if (trailingPath) { 215 // Replace slashes with underscores for the GA event label 216 formattedPath = trailingPath[1].replace(/\//g, '_'); 217 } 218 219 // Push event to the dataLayer for GTM 220 window.dataLayer = window.dataLayer || []; 221 window.dataLayer.push({ 222 'event': 'custom_form_submit', 223 'form_name': 'contact_' + formattedPath // Dynamic form name based on URL 224 }); 225 226 } catch (error) { 227 console.error('Error tracking form submission:', error); 228 } 229 }); 230 $('#gform_7 input[type=submit]').on('click', function(e) { 231 try { 232 window.dataLayer = window.dataLayer || []; 233 window.dataLayer.push({ 234 'event': 'custom_form_submit', 235 'form_name': 'newsletter_alt', 236 }); 237 } catch (error) { 238 console.error('Error tracking newsletter alt:', error); 239 } 240 }); 241 $('#gform_5 input[type=submit]').on('click', function(e) { 242 try { 243 window.dataLayer = window.dataLayer || []; 244 window.dataLayer.push({ 245 'event': 'custom_form_submit', 246 'form_name': 'tender', 247 }); 248 } catch (error) { 249 console.error('Error tracking tender:', error); 250 } 251 }); 252 253});
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.