I've created a GA Goal (custom event) in my dashboard, as well as added the onClick function to the <a></a> I'm seeking to track.
However the click event isn't registering in my Google Analytics > Behaviors > Events > Overview dashboard.
Here is the 'onClick' function:
onclick="ga('send', { hitType: 'event', eventCategory: 'Learn More Buttons', eventAction: 'Click', eventLabel: 'Our Founder', eventValue: 10});"
Here is a screenshot of the Goal Details in my Google Analytics account:
I've also installed the Google Analytics debugger for Chrome and am not receiving an error messages.
Looking under the real-time tab within the GA dashboard solved my problem.
Related
I want to track outbound link clicks on my site. I have Google Analytics on my site in terms of having the global site tag (gtag) in the head.
I'm happy to add the onClick event to each link as there's only a few. Can I just add onclick="ga('send', 'event', 'Category', 'Action', 'Label', 'Value');" to each link?
Basically I just tried this and the events are not showing in the Realtime stats so I'm not sure if I'm missing something.
You can't mix Universal Analytics code and gtag code. If you have in head gtag snippet, you have to use its syntax for send an event:
gtag('event', <action>, {
'event_category': <category>,
'event_label': <label>,
'value': <value>
});
https://developers.google.com/analytics/devguides/collection/gtagjs/events
Measure outbound links with gtag.js: https://support.google.com/analytics/answer/7478520?hl=en
I set up Google Analytics on my site to track events. However, some default events, i.e. purchase, and exception events do not appear in my Analytics reports. All my custom events appear in the reports as expected. The begin_checkout default event also appears. This inconsistent behavior has me confused.
I can work around this problem by exclusively using custom events, but I don't think I should have to as I'm simply following the documentation. See below for my exception event.
gtag('event', 'exception', {
'description': errorStringDefinedEarlier,
'fatal': false
});
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'])">
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.