Skip to content

Add an "onClick" field to submit button#109

Open
robertseaton wants to merge 4 commits intokraftbj:developfrom
robertseaton:develop
Open

Add an "onClick" field to submit button#109
robertseaton wants to merge 4 commits intokraftbj:developfrom
robertseaton:develop

Conversation

@robertseaton
Copy link
Copy Markdown

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
Copy link
Copy Markdown
Contributor

-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants