ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Any way to add my own Javascript onSubmit code to Mailing List signup form?

September 07, 2011 9:21pm

Subscribe [2]
  • #1 / Sep 07, 2011 9:21pm

    Susan

    81 posts

    What I want to do, ultimately: Add a Google Analytics event code to the mailing list signup form. In order to track goals.

    Google Analytics says I can add an event to a form’s submit button.

    Google Analytics JS code (from here):

    onSubmit="pageTracker._trackEvent('Goals','MailingListSignup');"

    In order to do that, I need to get deeper access to the form that’s generated by exp:mailinglist:form

    The result would look something like this:

    <form id='mailinglist_form' method="post" action="http://my.site.url/" onSubmit="[INSERT ANALYTICS SNIPPET HERE]" >

    How do I do that in EE?

    If I cannot do that in EE, does anyone know of another way to meet my ultimate aim of having Analytics GOALS track mailing list signups?

  • #2 / Sep 08, 2011 2:27pm

    Kevin Smith

    4784 posts

    Hi Susan,

    Right now, the Mailing List tag doesn’t provide a way for you to add any extra parameters to the HTML form element, but that would be a great feature request. Since it’s not something that’s possible with the native EE tags, would you like me to move this thread to Community Help to see if anyone else might be able to offer you a different route to take?

  • #3 / Sep 08, 2011 3:17pm

    Susan

    81 posts

    You can place this wherever you like. I’ve sorta come to the conclusion that the two ways of working with it are to either use freeform or to use onSubmit. Both by solspace. (former=free, latter = $9.95)

    I guess I’d have to add a feature request, too.

  • #4 / Sep 09, 2011 5:02pm

    Kevin Smith

    4784 posts

    Oh yes, I’d recommend onSubmit by Solspace for this. I totally forgot about it, but this is what I would use to accomplish this. It might not be a bad idea to add a Feature Request as well so that our devs know you’d like to see it happen.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases