Hi Andrija,
The plugin does not have built-in support for google analytics event tracking. However, there are a few different PHP- / WordPress-based action hooks that you could attach custom code to, including embedding JavaScript code. I would suggest checking out the process_form_submission.php page where we’ve included the following actions:
yikes-mailchimp-after-submission
yikes-mailchimp-after-submission-$form_id
yikes-mailchimp-form-submission
yikes-mailchimp-form-submission-$form_id
Would this help solve your current task?
Also, you’re not the first person to ask for Google Analytics (or similar software) support, so we hear you and will try to prioritize that.
Hope that helps,
Kevin.
Edit: Andrija, I answer a similar question in this thread (https://wordpress.org/support/topic/javascript-subscribed-event/) and thought that may be worth reading through.
Hi Kevin,
Thanks for the heads up, I will look into these hooks.
It would be very helpful to have that option out of the box inside the plugin or at least well documented somewhere (knowledge base for example) like mc4wp has it.
Cheers,
Andrija
Plugin Contributor
Tracy Levesque
(@liljimmi)
🏳️🌈 YIKES, Inc. Co-Owner
Hi Andrija,
We have added this to our to-do list.
Thank you for the suggestion!
-Tracy
Tnx, Tracy, I appreciate it!
And for all of you that want to do this, this is how I solved it:
add this into functions.php (I used child theme):
function whatever_you_want(){ ?>
<script>
ga('send', {
hitType: 'event',
eventCategory: 'Category',
eventAction: 'Action',
eventLabel: 'Label'
});
</script>
<?php
add_action( 'yikes-mailchimp-after-submission-1', 'whatever_you_want' );
NOTE:
yikes-mailchimp-after-submission-1 – Replace the last number (1) with the ID of your form
Hi @kokan87,
If you’re still looking for it, better support for Google Analytics has been added.
Check out this article from our knowledge base: https://yikesplugins.com/support/knowledge-base/add-google-analytics-event-tracking/.
Cheers,
Kevin.