kraftbj / genesis-enews-extended

WordPress widget to provide additional functionality to the Genesis eNews widget.
https://kraft.blog/genesis-enews-extended/
Other
12 stars 15 forks source link

Add an "onClick" field to submit button #109

Open robertseaton opened 10 years ago

robertseaton commented 10 years ago

Hey, Brandon,

Love the plugin. I use it across a couple of different Wordpress installs -- great stuff, thanks!

I wanted to track clicks on different mailing list signup forms across the site, to see what is working and what isn't. The easiest way to do this was to use Google Events tracking via an onClick parameter. So I hacked together a version of the plugin that supports that.

Concretely: screen shot 2014-09-12 at 11 35 42 pm

And this changes the generated HTML to this:

 <input value="Join Us" id="subbutton" onclick="ga('send', 'event', 'Button', 'OptIn', 'Sidebar - Top');" type="submit">

Not sure if this is something you're looking to add support for, but I figured I'd submit the pull request anyways. Oh, and my PHP skills are completely limited to what I've learned breaking WordPress, so, uh, buyer beware.

GaryJones commented 9 years ago

-1 for adding obtrusive JavaScript. Having the plugin trigger a JS event (see #68) is a good thing, but forcing an event through HTML attributes should not be the way to go.