I had a website where there was a link to a hotel booking engine and had been using onSubmit to record a form submission as an event.
However it didn't seem to be recording properly - the figures were too low.
So, I thought that maybe changing to onClick would help - so the code on the form would look like this:
<form id="bookingEngine"
class="bookingEngine"
name="bookingEngine"
action="redirect.php"
method=POST
target="_blank"
onClick="ga('send', 'event', 'Booking', 'Website');
">
This works, except now the figures are much higherand look as if maybe overreporting?
Is this right, could the onClick on a form tag be recording something other than the number of forms submitted?
A more simplistic explanation would be that the onclick tracks when an element is clicked, regardless of the outcome or the context in which the element was clicked, whereas the onbusmit tracks when a form button is clicked and the form successfully submitted. So if there were errors in the form that invalidated the form, and it doesn't get submitted, then the onsubmit action would not occur.
Related
I have a form like the following:
<form id="form-12" data-length="120" data-height="240">
<!-- different input fields -->
</form>
I can track the formSubmit event but what i need to include into the event are the values inside the data-attributes. How is this possible with Google Tag Manager? Do i need to to this with Javascript or is there another solution?
Open GTM preview, submit the form, select the form submit event in the preview and inspect the state of your variables on the submit event. You can use any of them.
You won't have the data-attributes among them, however.
You will have to use JS to parse out all the attributes on formSubmit if the attributes are still there on it.
It's worse if they're not. Then you would have to make them available for the future submit on pageload, on button click or on a different suitable trigger.
I'm running into an issue for a form submission event firing too often (200x). The trigger for the event is created from the GTM standard Trigger Type of "Form Submission" where we're checking validation and have specified the conditions to be only on the Page URL where the form exists. We've tested it in GTM preview mode and seeing that the event fires.
Update 1/28-
The form is on a pop-up through our homepage (https://mybrightwheel.com) after the user clicks on "Request a Demo" (so the event fire should not happen on this initial button click). The event fire should occur after they get into the demo request form and complete a successful form submit. And below that is a shot of the trigger. Any help here is appreciated.
That trigger hasn't specified which button it's firing on. You have 2 buttons in that screenshot, it's recording both. You need to tell it to fire on one button or the other by specifying link text or link url (i.e. where the user ends up on clicking the link)
I have a newsletter form on my website which is getting track on every hit of submit button. But now I recognize that if I simply hit submit button without filling any email than also it get track by GA code.
I want my newsletter form should only be tracked on successful submission and not on any blank submission.
You need to bind your event tracking to a successful form submission. It sounds like you are currently binding it to the click event on the submit button.
Start by getting your tracking event bound to submit event of the form (and not click event of the button) and then you'll have to write some code to find out when the form submission is valid.
Without further information about you page construction no-one can help any more than this.
When I create a tag to listen for form submissions using Google Tag Manager.
For my ajax submitted form which does not go to a new page, the submission of a form does not fire the gtm.formSubmit event into the data layer.
What should I do instead?
I need a "codeless" solution to detect form submission and to capture the submitted values.
I ran into another potential reason for this as well and thought I'd drop it in here.
In the Form Submit Listener, you need to have Check Validation unticked for AJAX forms (if the Submit button is blocked from doing a normal submit, as you would do with AJAX forms, this option blocks the listener from firing the correct event).
I have an ajax submitted form and the formSubmit click listener and event tags are working for me.
You might be doing this already, but just to double check;
You are adding 2 tags - the formSubmit listener and the Analytics event tag for that event?
Are you setting up the filters correctly (i.e. including event equals gtm.formSubmit, and the appropriate page?)
If it still isn't working, another suggestion is to use a simple click listener, then filter for both the page the form is on and the id of the submit button.
Here is how Google recommends doing it.
Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
Add a tag of type Event Listener > Form Submit Listener. You can name it “Form Submit Listener”. Add a single firing rule of "All pages", or, for the specific page(s) on which you want to listen for form submissions.
Add a rule (named "Form Submit" for example) with the following condition:
{{event}} equals gtm.formSubmit
Add an Analytics event tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Event). Add the rule you created in the previous step as the firing rule (for example, "Form Submit"). Enter a Category, Action, and and Label for the event. For example, you might use the following:
Category "Forms"
Action "Submit"
Label "Lead Gen".
Save a version of the container and publish it.
I've a form with different field, a validation summary and a button Sign up!
When I click on Sign up, if a field is empty, it active validation summary and until here there's no problem.
So the problem is that I would want active a jQuery script after it was clicked Sign up button and it appeared validation summary.
I try with
$(this).load(function()
but in effect it occur when the page is load and not after the button is clicked.
I try also use button's onclick ,but I have to use script after onclick and not while.
I used Validation group for all field of form, also button and for this reason it seems doesn't postback!
Um your question is a bit unclear to me but wouldn't this work ?
$("#sign_btn").click(function(){
alert("I was clicked");
});
sign_btn is the ID of the button.