Google Anlaytics Goal Tracking
-
Hello,
I use Yikes Mailchimp form in my wordpress account. How do I track the form submissions in google analytics? I checked this article https://yikesplugins.com/support/knowledge-base/add-google-analytics-event-tracking/.
Where should the below code be inserted? I use google tag manager as well. Can this entire code be added in GTM tag? Please explain the procedure.
add_action( ‘yikes-mailchimp-google-analytics’, ‘yikes_mailchimp_google_analytics’, 10, 1 );
function yikes_mailchimp_google_analytics( $form_id ) {
?>
<script type=”text/javascript”>var form_id = <?php echo $form_id; ?>;
// Fire off GA event for a failed subscription
function yikes_mailchimp_google_analytics_failure( response ) {(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);ga( ‘create’, ‘UA-xxxxx-1’, ‘auto’ );
ga( ‘send’, ‘event’, ‘mailchimp-subscribe’, ‘subscription-failed’ );
}// Fire off GA event for a successful subscription
function yikes_mailchimp_google_analytics_success( response ) {(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);ga( ‘create’, ‘UA-xxxxx-1’, ‘auto’ );
ga( ‘send’, ‘event’, ‘mailchimp-subscribe’, ‘subscription-successful’ );
}</script>
<?php
}The page I need help with: [log in to see the link]
The topic ‘Google Anlaytics Goal Tracking’ is closed to new replies.