I have a form on my site that, upon a successful completion, triggers a confirmation message in a modal. I need to be able to track the conversions on this form. I think I need an event tracker here, but I can't figure out where I'd put it.
The form is at http://www.nearlynewlywed.com/a/sell
The best practice is to create a virtual page view that will simulate a "thank you" page that will trigger the goal.
Execute this JS code when the form is validated and submitted:
_gaq.push(['_trackPageview', '/your-directory/form/thank-you']);
If you use Universal Analytics, then:
ga('send', 'pageview', '/your-directory/form/thank-you');
Now the thank you page will be rendered as a pageview, which will appears on your reports and Goals' funnel visualization. Remember to set the "/your-directory/form/thank-you" as the goal destination on Google Analytics.
If I understand your question correctly, you should push and event to GA when your form is validated and it passes. That means, if every field is ok, then at the same time you send the command to open the modal window you send a ga tracking command like this.
_gaq.push(['_trackEvent', 'Form', 'Success', 'Form x was completed']);
You could do something like this with jQuery
$('#formId').on('submit', function(){
_gaq.push(['_trackEvent', 'Form', 'Success', 'Form x was completed']);
});
OR add this to your form HTML tag
<form action="action.php" onsubmit="_gaq.push(['_trackEvent', 'Form', 'Success', 'Form x was completed'])">
Related
While defining tag and triggers in Google Tag Manager, is there a way I could define that specific information from my client goes into GA4? for example I want to send the so-called store code whenever a user click on a button, so that I can understand exactly which store has had this click. The click event is not my point, I have already defined the tag and trigger, my problem is that why in the response GA4 gives me some info is missing.
in my Tag I have defined a new event with the parameter shown in photo:
then the trigger is
Thank you in advance
You can just modify the parameter name like this
If this setting is not working. Then the problem will be the {{Click Text}} is not returning as you expected.
Ok I found a way to send info, based on this link [GA4] Custom events which is a JavaScript code. However this is not what I was searching for because it is dependent to coding part and I wanted something which I can do from GTM
<script>
/**
* The following event is sent when the page loads. You could
* wrap the event in a function to call the event when certain
* events (e.g., a click event) happen on your site.
*/
gtag('event', 'Your Event Name', {
'your_param1': 'value 1',
'your_param2': 'value 2',
});
</script>
I have a page setup with the following GA JavaScript on the page to track pageviews
ga('create', 'UA-xxxx-xxx', 'auto');
ga('send', 'pageview', location.pathname);
I also have the following JavaScript within document.ready to track an Event
$(document).on('click', 'button[type="submit"]', function () {
if (typeof (ga) !== 'undefined') {
ga('send', 'event', 'Your Details', 'Save Address Change');
}
});
Within all development and test environments, the code fires only when it should (the form contains only ONE button) but in LIVE, the Event is almost in line with the pageview number (and the backend data confirms that the button has not been pressed as it is logged in the SQL database as it fires an INSERT statement). When I attempt to debug the JS, the event does NOT fire
Is there any way the pageview event on my form could then be triggering the event? Caching?
Using the secondary dimensions, I cannot find any data that tells me what or who is triggering this event on almost every pageview. All it confirms is that this is not isolated to one browser
The code looks like it would operate the way you would hope, so there must be something else going on... This isn't particularly an answer as much as it is other things to check that may lead to an answer:
How many Unique Events vs. Total Events are occurring for "Your Details"?
Are there any other submit buttons elsewhere on the page (search, subscribe, etc)?
Any chance you're loading your tracking script (where the event listener is) more than once?
How about spam bots? Have you noticed many server-side crawlers? This wouldn't be caused by "ghost" spambots, so check for Full Referrer as a secondary dimension.
Does this appear on both your unfiltered and filtered views?
Are any other core metrics (users, sessions, pageviews, bounce rate) in your reports odd?
Create a segment for just users who have triggered this event and look through all of your other reports. Are they following a typical funnel/path that you would expect?
Check the User Explorer to see if you can find a specific user who triggered the event. What else did they do? Does it look like a normal users?
You could add a custom dimension of Client ID and parse the GA cookie to track which CIDs are triggering the event (it would help you find them in the User Explorer).
Other custom dimensions that could help you get more context clues: Timestamp, Hit ID (random ID assigned to every individual hit), PHP Referrer.
The long shot: any chance some other script is triggering a click on that button?
I hope something here helps you.
I know this is possible to track how many people have actually clicked on the submit button of form, but my form has a validation, if someones click on submit without entering a value, GA will count this, but this is not a real submission.
How do i track how many people have actually submitted the form using GA?
please let me know
thanks
You can output the GA code on success of your post request. A basic in page php example would be something like this:
if(isset($_POST)){
echo "<script>_gaq.push(['_trackEvent', 'Contact', 'Inquiry', 'Inquiry Form', 0, false]);<script>";
}
You can also use the onSubmit function. A client side solution would be this:
<form id="form-name" name="form-name" action="submission-url-goes-here" method="post"
onSubmit="_gaq.push(['_trackEvent', 'FormName', 'FormSubmit', 'FormSubmissionCompleted']);">
I would like to implement GA ecommerce code on my shop, but I have one problem - there is no "thank you page".
It works like client click on the button "confirm" and then appears jquery alert "thank you for buy" without reloading page etc. that`s all
Is some possibilities to implement ecommerce with full functionalists in such case?
I would suggest to bind an event listener to the button "confirm" with function which will send all ecommerce data to GA. Something like this:
$("button[name=confirm]").on("click", function(){
_gaq.push(['_addTrans',
...
]);
_gaq.push(['_addItem',
...
]);
_gaq.push(['_trackTrans']);
});
I have google analytics on my site.
One page has a button which when pressed executes some javascript.
It would be nice to monitor the number of hits the button receives when people come to this page.
Can anybody suggest the easiest way to achieve this with google analytics ?
Are there any best practices to do this ?
thanks
You can trackPageview in the link's onclick handler:
http://www.google.com/support/googleanalytics/bin/answer.py?answer=55521
<a href="javascript:void(0);"onClick="javascript:pageTracker._trackPageview('/folder/file');" >
This inflates your pageviews though, so it may be better to so use GA event tracking:
http://code.google.com/apis/analytics/docs/tracking/eventTrackerOverview.html
Play
Updated Answer
Here is the new method for Google Analytics event tracking:
<button onClick="ga('send', 'event', 'Category', 'Action', 'Label');" >Button text</button>
Category: Typically the object that was interacted with (e.g.
'Video')
Action: The type of interaction (e.g. 'play')
Label (optional param): Useful for categorizing events (e.g. 'Fall Campaign')
More info here: https://developers.google.com/analytics/devguides/collection/analyticsjs/events
The google analytics snippet sends google the page URL (among other things, probably) every time it's executed. I don't think you will be able to use it to count button clicks. If you execute the same snippet, it will keep sending the page's URL which is hardly valuable. If you manage to change the URL it sends, you might be able to get something...
Update:
You were right and I was wrong: google analytics does in fact support tracking events other than page loads.