• Resolved magneting

    (@magneting)


    Hi, I use Google Tag Manager and I want to track events / conversions on succesfully send form. I tried to set up event tracking from this comment – https://www.ads-software.com/support/topic/event-tracking-16/#post-9752485.

    So I tried this code in functions.php (in child theme):

    /*Mailchimp event Tracking*/

    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 successful subscription
    function yikes_mailchimp_google_analytics_success( response ) {
    ga( ‘create’, ‘UA-XXXXXX’, ‘auto’ );
    ga( ‘send’, ‘event’, ‘mailchimp-subscribe’, ‘subscription-successful’ );
    fbq(‘track’, ‘CompleteRegistration’);
    }

    </script>
    <?php
    }

    /*Mailchimp event Tracking*/

    But I have this alert on front end of every page:
    Warning: Use of undefined constant ‘yikes – assumed ‘‘yikes’ (this will throw an Error in a future version of PHP) in /nfsmnt/hosting1_1/f/f/ffb1a4f4-7f07-4e86-94a9-5462dca84a8c/vidadu.net/web/wp-content/themes/ark-child/functions.php on line 56

    Warning: Use of undefined constant mailchimp – assumed ‘mailchimp’ (this will throw an Error in a future version of PHP) in /nfsmnt/hosting1_1/f/f/ffb1a4f4-7f07-4e86-94a9-5462dca84a8c/vidadu.net/web/wp-content/themes/ark-child/functions.php on line 56

    Warning: A non-numeric value encountered in /nfsmnt/hosting1_1/f/f/ffb1a4f4-7f07-4e86-94a9-5462dca84a8c/vidadu.net/web/wp-content/themes/ark-child/functions.php on line 56

    Warning: Use of undefined constant google – assumed ‘google’ (this will throw an Error in a future version of PHP) in /nfsmnt/hosting1_1/f/f/ffb1a4f4-7f07-4e86-94a9-5462dca84a8c/vidadu.net/web/wp-content/themes/ark-child/functions.php on line 56

    Warning: A non-numeric value encountered in /nfsmnt/hosting1_1/f/f/ffb1a4f4-7f07-4e86-94a9-5462dca84a8c/vidadu.net/web/wp-content/themes/ark-child/functions.php on line 56

    Warning: Use of undefined constant analytics’ – assumed ‘analytics’’ (this will throw an Error in a future version of PHP) in /nfsmnt/hosting1_1/f/f/ffb1a4f4-7f07-4e86-94a9-5462dca84a8c/vidadu.net/web/wp-content/themes/ark-child/functions.php on line 56

    Warning: A non-numeric value encountered in /nfsmnt/hosting1_1/f/f/ffb1a4f4-7f07-4e86-94a9-5462dca84a8c/vidadu.net/web/wp-content/themes/ark-child/functions.php on line 56

    Warning: Use of undefined constant ‘yikes_mailchimp_google_analytics’ – assumed ‘‘yikes_mailchimp_google_analytics’’ (this will throw an Error in a future version of PHP) in /nfsmnt/hosting1_1/f/f/ffb1a4f4-7f07-4e86-94a9-5462dca84a8c/vidadu.net/web/wp-content/themes/ark-child/functions.php on line 56

    This is Line 56 – add_action( ‘yikes-mailchimp-google-analytics’, ‘yikes_mailchimp_google_analytics’, 10, 1 );

    NOW I DELETED THAT CODE, BECAUSE THAT ALERT WAS ANNOYING ON SITE

    What is wrong?

    Thanks for any help :).

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @magneting,

    I think something must’ve went wrong in the copy and paste – it looks like the editor is not recognizing the code as PHP and is throwing all types of errors.

    Try copying the code from our knowledge base: https://yikesplugins.com/support/knowledge-base/add-google-analytics-event-tracking/.

    Let me know how that works for you.

    Thank you,
    Kevin.

    Thread Starter magneting

    (@magneting)

    Hi @yikesitskevin ,

    thanks for help! Yes you were right, I copied code directly from post in this forum and some characters were changed.

    Here is code I used and it is working:

    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 successful subscription
    			function yikes_mailchimp_google_analytics_success( response ) {
    			ga( 'create', 'UA-XXXXXXXXX', 'auto' );
    			ga( 'send', 'event', 'mailchimp-subscribe', 'subscription-successful' );
    		}
    
    	</script>
    	<?php
    }
    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Awesome. Glad it’s working. Let us know if you need any more help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Event / Conversion tracking – Google Tag Manager’ is closed to new replies.