Event Tracking - Web Tracking (ga.js) not working on Mobile - google-analytics

I am trying to capture an event when the user clicks a link on my website.
I have added the tracking code at start of <body> tag
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-64301593-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
and then I am using
onclick="_gaq.push(['_trackEvent', 'landing_page', 'i_am_interested_click']);
on the <a> tag where I want to track an event.
It is working perfectly fine for all browsers on Desktop and I am able to see the events on Google Analytics Realtime -> Events tab. However same thing does not work for any browsers on mobile (I have tried Chrome and Firefox).
I have another hyper-link on the same page where I am tracking another event, this time by creating a jquery listener for the on-click event. However, that also does not work for mobile browsers (works on Desktop browsers).
The jquery code is as below:
$("#contact_me_button").click(function(){
$(this).fadeOut("slow", function() {
$(this).html("<a href='tel:+918695707070'>+918695707070</a>");
$(this).fadeIn("slow");
});
fbq('track', 'Lead');
_gaq.push(['_trackEvent', 'landing_page', 'call_attempted']);
});
Need help as I am new to this.
Thanks in advance !

Related

Google analytics event tracking inconsistent

We have implemented GA for tracking clicks as a button and registering them as conversions so we can track them. Our GA include looks like this:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setDomainName', 'XXXXXXXX.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Our code to trigger the event looks like this:
<input type="submit" name="" value="Contact" onClick="_gaq.push(['_trackEvent', 'Property', 'Click', 'Inquiry']);" />
We have the code tracking, but it seems to only pick up a fraction of the conversions. It does record conversions but it doesn't seem to get them all. For instance a couple days ago, we had 17 conversions (we can verify by copies of email) but GA only recorded 1. The site runs always on SSL if that matters.
Can anybody see any obvious reasons as to why we're not tracking all conversions? Thank you!
Google Analytics submits data as parameters on an image request -- the problem is that browsers will cancel pending image requests when navigating to a new page, and it's hit or miss whether the image request gets out before being canceled.
The most common solution involves adding a slight delay (150ms seems to work) after the _trackEvent and before the actual form submit.

how to check which version of Google Analytic code is working?

I am working on a website, and i want to do record event event on the website. for that i have searched on Google and found Event Tracking. but i how to check whether i am using ga.js or analytic.js and which is better to use and why.
My google Analytic code is:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '[TRACKING_ID]']);
_gaq.push(['_setDomainName',document.domain]);
_gaq.push(['_setAllowLinker',true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
please help me.
Universal Analytics does not use the .push syntax. Instead, it has a function ga().
You apear to not be using universal analtyics you should check this link on how to work with Event Tracking: Event Tracking - Web Tracking (ga.js)
This link should help you understand the diffrence: About Universal Analtyics

jQuery to track Google analytics events not working

I'm trying to use google anayltics events but so far without any success..
What I'm doing is loading 5 pages using jQuery load function
and I want to track the "Next button" for each load. but looks like i'm doing something wrong..
This is the next button event code:
$('.NextButton').click(function () {
_gaq.push(['_trackEvent', 'fz_main_page', 'clicked']);
installation.load_page({ inner_page: next_page, comid: data.comid, outerid: data.outerid, single_app: "1" });
});
Analytics Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25162785-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
What am I doing wrong?
It's possible that the installation.load_page function is preventing the trackEvent from firing. Try wrapping your load function in a setTimeout:
setTimeout('installation.load_page({ inner_page: next_page, comid: data.comid, outerid: data.outerid, single_app: "1" })', 100);
Install the Google Analytics Debugger. Look in the console (control, shift, j) for the event tracking processing.
If you don't see all of your events tracking there, then something else is up with the tracking code.

Google Analytics reports to be receiving data, but none is showing up

Hi recently redesigned my site (http://bit.ly/gwrYwb) which was formerly tracking pageviews properly via Google Analytics. After the redesign, I inserted the exact same code right before the </head> tag:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
(The UA number is correct on the actual page.) However, GA is mysteriously reporting zero pageviews/visits, even though it claims to be receiving data. Has anyone experienced a problem like this before? The only other JS I'm using is including jQuery, as well as a widely-used jQuery plugin on one of my pages.
This is kind of lame, but have you checked your profile filters? You might still have old filters (for the former website) applied that filter all urls out.
We had this problem with another website and were debugging for weeks until we found this simple solution...

Analytics - Email tracking

I'm trying to track my email links with Google Analytics, but for some reasons it does not work.
Here is my code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'xxxxxx']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
and here's the onClick function in page source code:
mail#mail.sk
I tried same tracking for link on other page and it worked. After I installed GA Debug, I found out that when I'm tracking mailto link, error shows up - Failed to load resource: mailto:mail#mail.sk
Does somebody have any ideas why there is an error and how to fix it?
Thanks
Wild guess :
Does adding javascript: before the content of your onClick even solves it ?
mail#mail.sk
I am assuming these links will be visible in email clients such as outlook and Gmail. Most, if not all, email clients strip all JavaScript out of email messages before displaying them.
If you would like to track email opens and other such information your only option is to use pixel tracking methods.

Resources