Created
August 3, 2021 09:32
-
-
Save alewolf/8f7adda46d46a89f85f3ee79d00f35ba to your computer and use it in GitHub Desktop.
create an event for Google Analytics custom dimensions in woopt WooCommerce Pixel Manager
This file contains hidden or 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_action('wp_head', function () { | |
?> | |
<script> | |
jQuery(document).on('wooptpmAddToCart', function (event, product) { | |
gtag('event', 'add_to_cart', { | |
"send_to" : wooptpmDataLayer.pixels.google.analytics.universal.property_id, // this is important to scope it to only GA UA and not send it to other properties | |
'ecomm_prodid': product.dyn_r_ids[wooptpmDataLayer.pixels.google.analytics.id_type], // you must make sure that the same ID type is being used for GA and Google Ads | |
'ecomm_pagetype': wooptpmDataLayer.shop.page_type, | |
'ecomm_totalvalue': product.quantity * product.price, | |
}); | |
}); | |
</script> | |
<?php | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment