These instructions are for Universal Analytics properties.
Here's a screengrab of what we'd like to clean up.
/** | |
* Modified to mockup sending an impression to GA for every slide displayed. | |
* | |
* I don't think this is really practical, but it was a customer request. | |
*/ | |
!function(e) { | |
var t = {}; | |
function o(a) { | |
if (t[a]) | |
return t[a].exports; |
<?php | |
/** MonsterInsights Email Hooks */ | |
// Sender email address filter hook. | |
function my_custom_sender_email_address( $original_sender_email_address ) { | |
return 'YOURSENDEREMAILADDRESS'; | |
} | |
add_filter( 'monsterinsights_email_from_address', 'my_custom_sender_email_address' ); | |
// Sender name filter hook. |
<?php // Ignore this line when copying/pasting this code to your child theme's functions.php file. | |
/** | |
* This example sets custom dimension #9 to be the WordPress | |
* post ID of the page/post being visited. | |
* | |
* This is compatible with MonsterInsights gtag code. This filter supercedes | |
* the monsterinsights_frontend_tracking_options_analytics_before_pageview | |
* filter. | |
* |
/** Exit - intent event demo */ | |
(function () { | |
if (!document.URL.includes("simple-form")) return; | |
const beforeUnloadListener = (event) => { | |
event.preventDefault(); | |
// GA code goes here. | |
// Below is an example using gtag.js API. |
<?php | |
/** | |
* Add to Child Theme's functions.php. | |
*/ | |
add_action( 'wp_footer', function () { | |
if (is_page ('2')) { | |
?> | |
<script>// Custom Label Snippet | |
let dl948914 = document.querySelector("a"); |
if (document.URL === "https://myverycool.site/form-page/") { | |
const subBtn949478 = document.querySelector( | |
"form#avia_contact_6935_contact-us-about input.button" | |
); | |
if (subBtn949478) { | |
subBtn949478.addEventListener( | |
"click", | |
function (evt) { | |
__gaTracker( | |
"send", |
<?php | |
/** Try to Remove Unnecessary "text/javascript" and "text/css" */ | |
function codeless_remove_type_attr($tag, $handle) { | |
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag ); | |
} | |
add_filter('style_loader_tag', 'codeless_remove_type_attr', 10, 2); | |
add_filter('script_loader_tag', 'codeless_remove_type_attr', 10, 2); |
<script> | |
// Adjust the bounce rate for GA. | |
setTimeout(function(){__gtagTracker('event', 'page visit 20 seconds or more', { | |
'event_category' : 'adjusted bounce rate', | |
})},20000); | |
</script> | |
<!-- Add to head section of page. --> |
(function () { | |
const searchForm = document.getElementById("search_form_map1881"); | |
const searchInput = document.getElementById("cspm_address_map1881"); | |
function sendEvent(event) { | |
// DEBUG | |
console.log(`Search city entered for searchForm is: ${searchInput.value}`); | |
// GA code goes here. Below is an example using gtag.js API | |
// via MonsterInsights. |