https://developers.google.com/web/tools/chrome-devtools/javascript/snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// Send an Crisp Chat event via gtag. | |
$crisp.push(["on", "chat:initiated", function() { | |
__gtagTracker('event', 'Test Event', { | |
'event_category' : 'test_event', | |
'event_action' : 'test_action', | |
'event_label' : 'This is a test event.' | |
}); | |
}]); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add missing form IDs for conversion tracking. | |
*/ | |
(function(){ | |
// Grab all the forms on the page. | |
const formElts = document.querySelectorAll("form"); | |
// If no forms, bail. | |
if (!formElts.length) return; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function monsterinsights_custom_add_ga4_tracking() { | |
echo "__gtagTracker( 'config', 'G-12345678' );"; // Change the measurement ID to yours. | |
} | |
add_action( 'monsterinsights_frontend_tracking_gtag_after_pageview', 'monsterinsights_custom_add_ga4_tracking', 15 ); | |
/** Add to child theme's functions.php file. */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Add data-vars-ga for MI Popular Posts Links */ | |
setTimeout(function() { | |
//const clStyle = "font-size: 20px; color: limegreen"; | |
const qSels = [ | |
".monsterinsights-inline-popular-posts-post a", | |
".monsterinsights-widget-popular-posts-list a", | |
".monsterinsights-products-popular-posts-list a", | |
]; | |
function addDataVarsGA(pps) { | |
pps.forEach((elem) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // This line is not needed for functions.php. | |
function monsterinsights_eu_compliance_tracking_didomi( $attributes ) { | |
$attributes['data-vendor'] = "didomi:google"; | |
$attributes['type'] = "didomi/javascript"; | |
return $attributes; | |
} | |
add_filter( 'monsterinsights_tracking_analytics_script_attributes', 'monsterinsights_eu_compliance_tracking_didomi' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(rn) { | |
let customerURL; | |
const customerURLElt = | |
document.querySelector(`#ex-templateBody td.ex-mcnTextContent table:nth-child(${rn}) tbody tr:nth-child(2) td a`); | |
if (customerURLElt) { | |
customerURL = customerURLElt.innerText; | |
} |