Title: Javascript subscribed event
Last modified: November 1, 2016

---

# Javascript subscribed event

 *  Resolved [aklapwijk](https://wordpress.org/support/users/aklapwijk/)
 * (@aklapwijk)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/javascript-subscribed-event/)
 * Is there any “subscribed” event that I can use in my JavaScript, for example 
   to add Google Analytics code or Facebook pixel conversion tracking?
 * I’m looking for an event that will only trigger when the form is used successfully
   to subscribe, something like this:
    [https://mc4wp.com/kb/form-events-google-analytics-tracking/](https://mc4wp.com/kb/form-events-google-analytics-tracking/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/javascript-subscribed-event/#post-8388404)
 * Hello [@aklapwijk](https://wordpress.org/support/users/aklapwijk/),
 * Thanks for the question.
 * Correct me if I am wrong: you’re looking for a place on the form editor in the
   admin view where you can add some JavaScript code that will fire when a user 
   successfully subscribes to a mailing list. Does that sound right?
 * If that’s the case, unfortunately there is no support for that at the moment.
 * If you’re looking for a PHP- / WordPress-based action hook to attach to, then
   check out the process_form_submission.php page where we’ve included the actions`
   yikes-mailchimp-after-submission`, `yikes-mailchimp-after-submission-$form_id`,`
   yikes-mailchimp-form-submission`, and `yikes-mailchimp-form-submission-$form_id`.
 * I hope I helped; please respond with more questions if you have them.
 * Thanks,
    Kevin.
 *  Thread Starter [aklapwijk](https://wordpress.org/support/users/aklapwijk/)
 * (@aklapwijk)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/javascript-subscribed-event/#post-8390959)
 * Hi Kevin,
 * Thanks for your reply.
 * Sounds about right; I’m looking for a way to add some JavaScript code that will
   file when a user successfully subscribes. Not via the form editor in the admin
   view however, but rather in my IDE.
 * For now I guess I will just use `.ajaxSuccess()` and use the `responseText` to
   detect if the submission was successful.
 * Thanks,
 * Anne
    -  This reply was modified 9 years, 6 months ago by [aklapwijk](https://wordpress.org/support/users/aklapwijk/).
 *  Plugin Contributor [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/javascript-subscribed-event/#post-8391368)
 * Hello Anne,
 * Now I understand what you’re trying to do; it can be accomplished as you said.
 * In the `yikes-mc-ajax-form.js` file (plugins/yikes-inc-easy-mailchimp-extender/
   public/js/yikes-mc-ajax-forms.js) you can add your custom code after line 91 (`
   if( response.success ) {` ). You can use the JavaScript variables from the `data`
   object to get the information you need, like form_id and email address. However,
   as you probably know, this code would get wiped out during an update so keep 
   that in mind.
 * Also, this will only trigger for MailChimp forms that are using the AJAX method.
   If any of them are going through PHP form submissions, the code would not fire.
   I would recommend using one of the PHP-/WordPress-based action hooks to achieve
   the same functionality as the AJAX.
 * I hope that helps; please let us know,
    Kevin
 *  Plugin Contributor [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/javascript-subscribed-event/#post-8396388)
 * Hi again Anne,
 * I just wanted to add that I’d recommend using the PHP-/WordPress-based action
   hooks instead of editing the JS file as this would allow you to put the code 
   in a separate area from the plugin, and therefore you would not lose any code
   or analytics data during / after an update.
 * Kevin.
 *  Thread Starter [aklapwijk](https://wordpress.org/support/users/aklapwijk/)
 * (@aklapwijk)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/javascript-subscribed-event/#post-8405031)
 * Hi Kevin,
 * Thanks for your help. I totally agree with you, it’s best to not edit the plugins
   code. I will use the PHP-/WordPress based action hooks as much as possible, however
   in some cases I would use JavaScript. For example when using AJAX, to change 
   styling of some elements after a user successfully subscribes, without a page
   refresh. I would do this in a separate area from the plugin though.
 * Thanks,
    Anne
 *  Plugin Contributor [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/javascript-subscribed-event/#post-8405682)
 * Sounds great, Anne; let me know if you need any additional help.
 * Also, if you’re enjoying the plugin, consider leaving us a friendly review or
   rating; they make our day!
 * Cheers,
    Kevin.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Javascript subscribed event’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/yikes-inc-easy-mailchimp-extender_a1c7e5.
   svg)
 * [Easy Forms for Mailchimp](https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/)
 * [Active Topics](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/javascript-subscribed-event/#post-8405682)
 * Status: resolved