Skip to content

Commit abd1da8

Browse files
committed
Add LFX analytics code
Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
1 parent ece5544 commit abd1da8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

web/wp-content/themes/lfevents/library/lfe-functions.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,29 @@ function lfe_insert_google_tag_manager_body() {
366366
}
367367
}
368368

369+
/**
370+
* Inserts LFX code on main Events site.
371+
*/
372+
function lfe_insert_lfx_head() {
373+
if ( ! is_lfeventsci() ) {
374+
return;
375+
}
376+
377+
wp_enqueue_script(
378+
'lfx-segment',
379+
'https://lfx-segment.platform.linuxfoundation.org/latest/lfx-segment-analytics.min.js',
380+
array(),
381+
null,
382+
false
383+
);
384+
385+
wp_add_inline_script(
386+
'lfx-segment',
387+
"if(window.LfxAnalytics&&window.LfxAnalytics.LfxSegmentsAnalytics){var analytics=window.LfxAnalytics.LfxSegmentsAnalytics.getInstance();analytics.init().then(function(){}).catch(function(error){console.error('Failed to initialize analytics:',error)});}else{console.warn('LfxAnalytics not found');}"
388+
);
389+
}
390+
add_action( 'wp_enqueue_scripts', 'lfe_insert_lfx_head' );
391+
369392
/**
370393
* Inserts Event-specific favicon if set, otherwise falls back to site favicon.
371394
*/

0 commit comments

Comments
 (0)