There are many great code snippets in their Gitlab. You might find more on their…
Formiantor GA Tracking
/*FORMINATOR TRACKING
* https://gist.github.com/wpmudev-sls/5fc34beaee5a34947cda67ccc6a56bff
* https://gist.github.com/patrickfreitasdev/46c9dbf946b3cc34a46ae3a24d58635b THIS ONE HERE GA ONLY
* */
add_action( 'wp_footer', function(){
/**
* Tracking ID and property number
*
* The tracking ID is a string like UA-000000-2.
* It must be included in your tracking code to tell Analytics which account and property to send data to.
* Help: https://support.google.com/analytics/answer/7372977
*/
$tracking_id = 'AW-XXXXXXXXX';
/**
* Default: true
* Set to 'false' if another plugin loads Google Analytics & Facebook Pixel tracking code property.
*/
$tracking_code = true;
?>
<?php if( $tracking_code ) { ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $tracking_id; ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push( arguments ); }
gtag( 'js', new Date() );
gtag( 'config', '<?php echo $tracking_id; ?>' );
console.log( 'Tracking Code placed' );
</script>
<?php } ?>
<?php
/**
* Forminator GA Integration
*/ ?>
<script type="text/javascript">
(function($){
$(document).on( 'forminator:form:submit:success', function( formData ){
var form_id = $(formData.target).find('input[name="form_id"]').val();
if( form_id == 71 ){
// Do something here...
}
if ( typeof window['gtag'] == 'function' ) {
<?php
/**
* Measure Google Analytics Events
* https://developers.google.com/analytics/devguides/collection/gtagjs
*/ ?>
//gtag( 'event', 'action', { 'event_category': 'category', 'event_label': 'label','value': 'value' } );
gtag( 'event', 'conversion', {'send_to': 'AW-941906725/gbQICLzsiJIYEKW2kcED'});
console.log( 'Tracking Tag fired' );
} else {
console.log( 'Google Analytics not detected. Aborted sending event...' );
}
});
})(jQuery);
</script>
<?php }, 99 );
Dieser Beitrag hat 0 Kommentare