Blexy Flexy - Answers
Home/Blexy Flexy/Answers- About
- Questions
- Polls
- Answers
- Best Answers
- Asked
- Followed
- Favorites
- Groups
- Posts
- Comments
- Followers Questions
- Followers Answers
- Followers Posts
- Followers Comments
- Questions
- Polls
- Answers
- Best Answers
- Asked
- Followed
- Favorites
- Groups
- Posts
- Comments
- Followers Questions
- Followers Answers
- Followers Posts
- Followers Comments
Track event in google analytics upon clicking form submit
Use Google Analytics hitCallback You can specify a custom callback function on the tracker object. _gaq.push(['_set', 'hitCallback', function(){}]); The callback is invoked after the "hit is sent successfully." If you want to track a click on a submit button and send the form afterwards you can useRead more
Use Google Analytics
hitCallback
You can specify a custom callback function on the tracker object.
The callback is invoked after the “hit is sent successfully.”
If you want to track a click on a submit button and send the form afterwards you can use the following code (uses jQuery) for your event:
Or as
onclick
one liner for your<input type="submit">
element:What it does it that it tracks the event
My category/My action
, uses jQuery to find the underlying form element of the submit button just pushed, and then submits the whole form.See: Google Analytics – Sending Data to Google Analytics – Hit Callback (thanks supervacuo)
UPDATE If you’re using modern analytics.js code with ga() function defined, you can write this as following:
See lessGoogle Analytics event tracking -Contact Form Submit
The most likely problem here is that your page is being unloaded before the event hit has time to send. When you submit a form on a web page, most browsers will stop executing JavaScript and start loading whatever new page the form's action attribute is pointing to. The general workaround for this iRead more
The most likely problem here is that your page is being unloaded before the event hit has time to send. When you submit a form on a web page, most browsers will stop executing JavaScript and start loading whatever new page the form’s
action
attribute is pointing to.The general workaround for this is to call
preventDefault
on the form’ssubmit
event, wait for the hit to successfully send to Google Analytics, and then manually re-trigger the form submit.Here’s how that might look (note: I’m using jQuery for simplicity):
The key part in the above code is the
hitCallback
function, which gets invoked when GA returns success from the event hit beacon.Event tracking with Google Tag Manager
Have you created a tag for Google Analytics Event? You'll have to map the event category to eventCategory, etc. And then set the rule to GA Event equal to GAevent.(see attached)
Have you created a tag for Google Analytics Event?
You’ll have to map the event category to eventCategory, etc. And then set the rule to GA Event equal to GAevent.(see attached)
Google Tag Manager: Eventtracking not working
Two things: You should have an event = GAEvent. You can create this by creating a new macro > Custom Event and setting the macro name to GAEvent. On your rule, you will need to add your event = GAEvent to your rule.
Two things:
You should have an event = GAEvent. You can create this by creating a new macro > Custom Event and setting the macro name to GAEvent.
On your rule, you will need to add your event = GAEvent to your rule.
See less