Tracking click on an "href" image as a goal in Google Analytics - google-analytics

thanks in advance for the help,
I have this code on my page:
a href="https://eshops.mercadolibre.com.mx/XXX" target="_blank" onclick="__ga('send', 'event', 'button', 'click', ‘URL’);">Mercadolibre
But I cant see the results reflected on Google analytics, I created a goal called "ClickOnLink" with details as follow:
Details
What am I doing wrong?

Your goal configuration specifies a value greater than 0, but the event your onclick is sending does not have a value associated with it. Either you send a value greater than 0, or you remove the value condition in your goal.
Make sure you have the same letter casing as well.

Related

Event not Trackable in Google Tag Manager

I am trying to do a tag that measures the number of times an element is clicked.
I follow the following steps to create the tag
Tag Config:
Track Type- Event; Category- Button Click; Action;Non-Interaction Hit- False;
Add Trigger:
Click on some clicks:
Click Text>>Click URL>> Click Path
I follow the complete steps, but somehow I'm not able to track the events. Please, somebody, help me to find out If somewhere I was wrong or forgot to add some steps in this procedure.
In your example it seems that Action has no value.
If so, you should assign a value to Action because it is a mandatory parameter for events.

Google Analytics - show pathname in label

We're tracking events on our website and we've managed to implement this:
ga('send', 'event', 'Download', 'completed', 'pathName/filename');
For when a user clicks on a pdf download link. The "pathName/filename" is eg. "whitepapers/mywhitepaper.pdf"
What should I write in the Goal details:
label equals to ...?
label starts with ...?
label regular expression ...?
In a way, the question is similar to this one, with the important difference that I've implemented that part with someone's help but I don't know what do to next in the Analytics to reflect that.
Thanks!
Serge

google analytics reading the report - click event detail?

I'm using google analytics and am using this code as an example to capture a click event.
ga('send', {
'hitType': 'event', // Required.
'eventCategory': 'button', // Required.
'eventAction': 'click', // Required.
'eventLabel': 'nav buttons',
'eventValue': 4
});
where do I find this data in the reporting?
what I am able to find is event catgory buton but I cant find where this button was clicked with eventValue 4.
Can you please help.
I'm pretty sure that you misunderstand what "event value" means - this is to monetize non-ecommerce events. Which means event value is a metric, which in turn means that the values for multiple events will be added up.
So, the only case where you could possibly see the value "4" is when you isolate one single event. Else you will see a total (or average) for all events with the selected category/action/label (depending on the report).

Visitor Custom Variable Google Analytics Help

I am using Google Analytics Custom Variables for a site I am working on. Here is the code snippet uploaded on the page.
_gaq.push(['_setAccount', 'UA-xxxxxxxxx-1']);
//]]>
</script>
<script>
//<![CDATA[
_gaq.push(['_trackPageview', 'searches/new/registration/complete']);
_gaq.push(['_setCustomVar', 1, "member type", "registered", 1]);
_gaq.push(['_trackEvent', 'registration', 'signup',,1]);
Although I am aware that the _trackPageview needs to be placed after the _setCustomVar call, I am still seeing numbers flow through into Google Analytics as 'member type=registered'. I do not want to dismiss these numbers and I want to make some sense of it before I amend this error in how the snippet was placed.
Any reason why I stil received visits for this Name-Value combination?
Thanks -
The Custom Var is set with a GA cookie, and is actually stored and sent on your next _trackPageview, that's why you can still see it, all you are doing to sending the data probably in a moment you don't want to (the next pageview).
Edit: Also as pointed out, it could go with your _trackEvent method, wich will end up doing the same thing, sending the data in a particular time you dont intent to, specially with events, wich are linked to interactions, so if no one triggers those in the page you are trying to set the customVar, it wont get set at all.
Because your custom variable's scope is set to 1, it'll still get fired by "trackEvent" (even without "trackPageview".
If your scope was set to 3 (page-level), it will then rely on "trackPageview" and will not register well with "trackEvent"

Firing 2 google analytics events with an outbound link

I have outbound links like this in my html:
<a href="http://www.example.com" class="gaLink1"
target="_blank" onCLick="ga_track_link('action', '123', 'abcde', 'fghij')">
<img src="http://www.example.com/image.jpg" alt="image name" height="180" style="max-width:153px;max-height:150px;" />
</a>
So, When there is a click on this image, the link www.example.com should open in a new tab, since there is target="_blank". Also, the onCLick event will call the function ga_track_link which is defined as:
function ga_track_link(action, id, name, source) {
_gaq.push(['_trackEvent', 'category 1', action, id+': '+name]);
_gaq.push(['_trackEvent', 'category 2', 'example', source, 15]);
}
This function is defined in the script section at the end of the html (inside the body section)
I'm observing in GA, there both events are tracked (category 1 and 2), but the amount of times that both are tracked is not equal. Category 2 appears almost half of times, which makes me think that the 2nd event is not always being fired.
I found this link http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55527
that suggests to put the function "ga_track_link" in the head section of the html and use a return False in the onClick function.
According to some other answers like When and why to 'return false' in JavaScript? , the return false statement would tell the event (onClick) not to be fired, which is not what I want, since I do want it to be fired but after my 2 GA events were fired.
So, I have 3 questions:
1) Is there any problem firing more than 1 GA event (with _trackEvent) on 1 click? What is the best way to do it?
2) Why Google Analytics link above states that the function should be placed in the head section of the html?
3) Can someone please clarify the "return false" statement's goal and how to use it correctly?
1) Is there any problem firing more than 1 GA event (with _trackEvent) on 1 click? What is the best way to do it?
No, no issue with that although you could do both with one push. One Push, Multiple Commands
2) Why Google Analytics link above states that the function should be placed in the head section of the html?
Because the user may click the link before the javascript has time to load on the page.
3) Can someone please clarify the "return false" statement's goal and how to use it correctly?
My understanding is that it prevents the default behavior of the element and if listed after your function call it should have no effect on that function call. This is just as stated in one of the answers to the question you cited:
<a href="#" onclick="doSomeFunction(); return false;">
In the Google Analytics support link you provided, the return false; is stopping the link from immediately sending the user off the site. It runs the tracking function before hand and then redirects the user to the external site after a delay. This allows the tracking code the time needed to be sent off before the redirect.
function recordOutboundLink(link, category, action) {
_gat._getTrackerByName()._trackEvent(category, action); //set tracking
setTimeout('document.location = "' + link.href + '"', 100); // redirect to external site after delay
}
Do you have target="_blank" on all links using your ga_track_link() function?
If the link is opening in the same window, it's possible that the tracking pixel requests made by _trackEvent might not have time to complete before the new page starts being fetched. If the link is opening in a new window, it's not a problem.

Resources