Title: Button shortcode attribute request: &#039;onclick&#039; event
Last modified: August 30, 2016

---

# Button shortcode attribute request: 'onclick' event

 *  Resolved [rotbieest](https://wordpress.org/support/users/rotbieest/)
 * (@rotbieest)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/)
 * Hi there Prali,
 * First of all, thanks for the great support so far and the regular updates with
   new features, keep up the good work!
 * Secondly, I was wondering if it would be possible to include an ‘onclick’ event
   via an attribute in the button shortcode?
 * The purpose of this is to track these button clicks via google analytics. This
   requires the following code to be added to the HTML hyperlink: onclick=”_gaq.
   push([‘_trackEvent’, ‘category’, ‘action’, ‘label’]);”
 * So that the HTML hyperlink looks like this: “<a” href=”[http://google.com&#8221](http://google.com&#8221);
   onclick=”_gaq.push([‘_trackEvent’, ‘category’, ‘action’, ‘label’]);” class=”wpi_designer_button”
   target=”” rel=””><i class=””></i><span class=”wpi_text”>LINK TEXT</span>””
 * In this code, the parameters ‘category’, ‘action’, and ‘label’ can differ per
   button
 * In order to be able to re-use the same button, it would be great to add this 
   via the button shortcode, for example: [wpi_designer_button id=12 link=”[http://google.com&#8221](http://google.com&#8221);
   onclick=”_gaq.push([‘_trackEvent’, ‘category’, ‘action’, ‘label’]);”]
 * Hope this makes sense to you 🙂
 * I would do this manually, but since the plugin makes use of shortcodes, we don’t
   have access to the HTML markup of the hyperlinks that are used in buttons.
 * Looking forward to hearing from you!
 * [https://wordpress.org/plugins/wpi-designer-button-shortcode/](https://wordpress.org/plugins/wpi-designer-button-shortcode/)

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

 *  Plugin Author [WooPrali](https://wordpress.org/support/users/wooprali/)
 * (@wooprali)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267713)
 * Hi,
 * Sure, I will add this feature in next version.
 * Thanks for your valuable feedback.
 * Regards,
 * Prali
 *  Thread Starter [rotbieest](https://wordpress.org/support/users/rotbieest/)
 * (@rotbieest)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267790)
 * Great to hear 🙂
 * May I kindly ask if you have any idea when you would be able to publish the next
   update?
 * Best regards
 *  Plugin Author [WooPrali](https://wordpress.org/support/users/wooprali/)
 * (@wooprali)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267833)
 * Hi,
 * i am planning to release new version in next month.
 * Regards,
 * PRALI
 *  Thread Starter [rotbieest](https://wordpress.org/support/users/rotbieest/)
 * (@rotbieest)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267890)
 * Thanks for your support, looking forward to your update!
 * Cheers
 *  Thread Starter [rotbieest](https://wordpress.org/support/users/rotbieest/)
 * (@rotbieest)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267915)
 * Hey Prali,
 * I just thought of something! 🙂
 * Would it also be possible to make these hyperlinks set to no-follow links? In
   other words, can you give the option to set the rel=”nofollow” attribute in the
   HTML hyperlinks?
 * I’m guessing you already thought of this, if you were planning to make extra 
   additions possible within the < a > opening tag? 🙂
 * Looking forward to hearing from you!
 *  Plugin Author [WooPrali](https://wordpress.org/support/users/wooprali/)
 * (@wooprali)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267921)
 * Hi,
    Sure I add rel attribute to button.
 * Regards,
 * Prali
 *  Thread Starter [rotbieest](https://wordpress.org/support/users/rotbieest/)
 * (@rotbieest)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267930)
 * Hey I’m back 😀
 * I’ve just discovered this rel attribute options is already a functionality after
   you’ve enabled it via the global settings of the plugin, didn’t know this setting
   was there.
 * Then, the ‘Rel’ field appears when creating a button where you can enter a value.
   Here, I entered: nofollow
 * However, even after succesfully saving (even checked in the database if it saved
   properly), it still does not function as it should. When checking the button 
   on the frontend, the HTML a rel attribute still says: rel=”” => so, empty!
 * Any ideas?
 *  Plugin Author [WooPrali](https://wordpress.org/support/users/wooprali/)
 * (@wooprali)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267931)
 * Hi,
 * I just fixed the rel attribute.
    Next release will be in few days.
 * Please update your designer button plugin.
 * Regards,
 * PRALI
 *  Thread Starter [rotbieest](https://wordpress.org/support/users/rotbieest/)
 * (@rotbieest)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267932)
 * Great, just updated and the rel attribute now works indeed, thanks!
    Looking 
   forward to your next release with even more additional features, love your work!
 *  Plugin Author [WooPrali](https://wordpress.org/support/users/wooprali/)
 * (@wooprali)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267933)
 * Thank you.
 * PRALI
 *  Thread Starter [rotbieest](https://wordpress.org/support/users/rotbieest/)
 * (@rotbieest)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267949)
 * Hi again, may I kindly ask for a status update regarding the ‘onclick’ feature?
 * I would like to use this with Google Tag Manager to push variables into the dataLayer
   in order to track these button clicks with Google Analytics.
 * Basically, like the ‘rel=’ attribute, this feature would mean an ‘onclick=’ field
   where the user would be able to put in the custom code.
 * Or, more generally and more robust perhaps, another solution would be if the 
   user could be presented a field in which he could put whatever code block he 
   wants, which would be inserted into the opening < a > tag?
 * Best regards!
 *  Plugin Author [WooPrali](https://wordpress.org/support/users/wooprali/)
 * (@wooprali)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267956)
 * Sure,
 * I will implement your request in next big version.
 * Regards,
 * Prali

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

The topic ‘Button shortcode attribute request: 'onclick' event’ is closed to new
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wpi-designer-button-shortcode_413a0e.
   svg)
 * [WPi Designer Button](https://wordpress.org/plugins/wpi-designer-button-shortcode/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpi-designer-button-shortcode/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpi-designer-button-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/wpi-designer-button-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpi-designer-button-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpi-designer-button-shortcode/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [WooPrali](https://wordpress.org/support/users/wooprali/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/button-shortcode-attribute-request-onclick-event-2/#post-6267956)
 * Status: resolved