SOLVED

Whether or not "ID attribute" can be added to submission button of Marketo form

Go to solution
Highlighted

Whether or not "ID attribute" can be added to submission button of Marketo form

Hi Community,

I was asked this question by my partner, web designer, who is supposed to implement this functionality.

Unfortunately, I have little knowledge of this field...

More concretely, we want to revise like this:

<<BEFORE>>

<button type="submit" class="mktoButton">SUBMIT</button>

<<AFTER>>

<button type="submit" id="news_letter_submit" class="mktoButton">SUBMIT</button>

JavaScript could achieve this we hope....

Hopefully we got some advice from a person with this experience.

Thanks in advance!

Tad

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level 10 - Community Moderator

Re: Whether or not "ID attribute" can be added to submission button of Marketo form

Of course, it's very easy to do.

But before I give you the code, I want to check on why you're doing this. Is it to style the button? Because the ID isn't necessary for CSS. Is it to send more data to the server? Because this won't work without a name and value assigned, and is much more easily (and equivalently) done with the addHiddenFields method.

View solution in original post

6 REPLIES 6
Highlighted
Level 10 - Community Moderator

Re: Whether or not "ID attribute" can be added to submission button of Marketo form

Of course, it's very easy to do.

But before I give you the code, I want to check on why you're doing this. Is it to style the button? Because the ID isn't necessary for CSS. Is it to send more data to the server? Because this won't work without a name and value assigned, and is much more easily (and equivalently) done with the addHiddenFields method.

View solution in original post

Highlighted

Re: Whether or not "ID attribute" can be added to submission button of Marketo form

Hi Sanford-san

Thanks for your advice!

As per your question, we are asking this because we implement "event

tracking" and need to classify different submission such as "News Letter

Submission Button" and "Require Demo Button".

This might clear the matter you have?

Best,

Tad

2016-04-24 13:27 GMT+09:00 Sanford Whiteman <marketingnation@marketo.com>:

<https://nation.marketo.com/?et=watches.email.thread> The Marketo

Marketing Nation Community

<https://nation.marketo.com/?et=watches.email.thread>

Whether or not "ID attribute" can be added to submission button of Marketo

form

reply from Sanford Whiteman

<https://nation.marketo.com/people/63ea064b55e61d1184c4e1e1cc5ee59b25d3a3a1?et=watches.email.thread>

in Products - View the full discussion

<https://nation.marketo.com/message/127956?et=watches.email.thread#comment-127956>

Highlighted
Level 10 - Community Moderator

Re: Whether or not "ID attribute" can be added to submission button of Marketo form

Hi! Changing/setting the ID won't affect the values sent to the server.  Your partner may be confusing a Marketo form for a native HTML form, where altering the name and value of a submit button will set an additional form field to be sent to the server (usually, this is used to distinguish two different actions that can result from the same form, such as "Delete Contact" or "Update Contact").  Marketo forms don't work this way.

If you want to use the the same form but add a "submission type" depending on the page you're on, just use addHiddenFields:

MktoForms2.whenReady(function(form) {             
form.addHiddenFields({                
  'LastSubmitButtonAction': 'news_letter'            
});        
});

Of course, you will have to add a custom field in your instance to hold this value.

Note that while there's nothing wrong with this approach, most users distinguish different submissions of the same form based on the URL that hosts the form (assuming, naturally, that a single URL will never use the same form for different purposes).  When you do it this way, you don't need to create a field to record the different events.

Highlighted

Re: Whether or not "ID attribute" can be added to submission button of Marketo form

Hi Sanford-san

Thanks for your advice!

We've decided to find some other resolution following you advice!

Thanks Again!!!

Tad

2016-04-25 11:59 GMT+09:00 Sanford Whiteman <marketingnation@marketo.com>:

<https://nation.marketo.com/?et=watches.email.thread> The Marketo

Marketing Nation Community

<https://nation.marketo.com/?et=watches.email.thread>

Whether or not "ID attribute" can be added to submission button of Marketo

form

reply from Sanford Whiteman

<https://nation.marketo.com/people/63ea064b55e61d1184c4e1e1cc5ee59b25d3a3a1?et=watches.email.thread>

in Products - View the full discussion

<https://nation.marketo.com/message/127943?et=watches.email.thread#comment-127943>

Highlighted
Level 10 - Community Moderator

Re: Whether or not "ID attribute" can be added to submission button of Marketo form

Great! Please mark as Correct when you get a chance.

Highlighted
Level 1

Re: Whether or not "ID attribute" can be added to submission button of Marketo form

Hi there!

Sorry to bring up that old thread, but this is the only one I could find and the solution is not quite what I imagined it to be. I'm in need of pretty much the same: setting an ID for the submit button on a marketo form. Tracking of CTAs in Segment/Google Analytics requires the button to have an ID and in the form editor there is no such option. How can I give each submit button a unique id that I can track?


Best regards,

Matthias