Support » Plugin: Easy Forms for Mailchimp » Event in Google Analytics

  • Resolved Wow Digital

    (@dmpp)


    I’ve used the code you have on your site at https://yikesplugins.com/support/knowledge-base/add-google-analytics-event-tracking/ and it works, the only issue is that I have multiple forms, and they’re all showing in Google Analytics as the same event.

    I tried changing
    ga( 'send', 'event', 'mailchimp-subscribe', 'subscription-successful' );
    to
    ga( 'send', 'event', 'mailchimp-subscribe', 'subscription-successful_<?php echo $form_id;?>' );
    and no luck. I’ve tried a few other things, but nothing is working. I thought that might append the form id number to the string.

    How can I make it so that the event action shows something unique for each form?

    • This topic was modified 1 week, 6 days ago by Wow Digital.
    • This topic was modified 1 week, 6 days ago by Wow Digital.
    • This topic was modified 1 week, 6 days ago by Wow Digital.
Viewing 1 replies (of 1 total)
  • Plugin Author Freddie

    (@fmixell)

    @dmpp,

    The form id should already be available in the JS if you’re echoing onto the page. You should also wrap that with absint to escape it. That will make sure you’re always getting an integer here.

    echo absint( $form_id );

    Since the form ID is already available in the JS form_id var you could try to pass that to GA.

    ga( 'send', 'event', 'mailchimp-subscribe', 'subscription-successful', form_id );

    If you’d like to get more specific using the Tag manager will most likely be a better option for you. You can view your site through the tag manager and test in real time to see if your tags are firing. You could associate this data with your Google analytics and problem solved.

    https://support.google.com/tagmanager/answer/7679217?hl=en

    Cheers,
    Freddie

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.