I placed the google analytics code in my magento site 4 or 5 days ago, I think I have waited enough and that the report should be working.
However I still see Page Load Time as 0.00.
If you see the generated code from magento its like this:
My website is this
<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
(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';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->
I'm able to get _trackPageLoadTime to work just fine.
You can simulate it by editing the __utma cookie. The second period delimited value is the unique user ID. Just change the second to last digit to be 0, and it will track page load time for you.
Since ga.js is configured to only run for 10% of traffic, and only around 30% of users have browsers that support is, it'll usually only collect data from 3% of your users.
Related
My pages load the site tag (gtag.js)
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxxxx-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxxxxx-1');
</script>
In Analytics I set up a goal:
Category > Equal to : Phone
Action > Equal to : Click
Label > Equal to : Call link
Value > Equal to : 0
The link looks like this:
(07) 1234 1234
What is wrong? I have this up for 72 hours now and click the links a few times without any result
I am trying to integrate the G+ API with my website and am having a problem. If you look at the console when loading the page, you will see the following errors:
GET https://accounts.google.com/o/oauth2/postmessageRelay?parent=http%3A%2F%2Fwww.pricewombat.com 400 (Bad Request) cb=gapi.loaded_0:436
Refused to display 'https://accounts.google.com/o/oauth2/postmessageRelay?parent=http%3A%2F%2Fwww.pricewombat.com#rpctoken=356505585&forcesecure=1' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
I'm just using the example code given on Google's website:
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js?onload=googlePlusOnloadCallback';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
If I run gapi.auth.signIn() in the console, nothing happens. I'm assuming the problem is related to the above errors when the page loads.
What's causing this problem and how do I fix it?
UPDATE:
I created a blank page on my website with this barebones code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'http://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</body>
</html>
I tried loading the above page with and without the authentication meta tags (not shown above) and am still getting the errors.
It seems like this has to be a problem on Google's end since I'm just using the most basic barebones example code and it's not working.
Well, apparently Google+ just had a brainfart or something, because the solution was simply to clear my cookies!
I tried using my website on another computer and the Google+ API worked fine (no errors), so I tried clearing the cookies on my desktop and lo and behold, it started working!
What I found out was that if the client has opened up the chrome for very long time, they would get this error. Once they close the chrome and reopen, they don't have any trouble with the issue. My solution was to download the script from the server, uploaded it to our server and made it as a backup download.
I have this code in my product page after an item has been added to cart:
<script type="text/javascript>
//<![CDATA[
(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';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
var _gaq = _gaq || [];
_gaq.push(['_setCustomVar', 1, 'Page Type', 'Product', 3])
_gaq.push(['_setCustomVar', 2, 'Product Name', 'Gold Bracelet', 3]);
_gaq.push(['_trackEvent', 'Product Page', 'Added To Basket', 'Gold Bracelet', , 0]); // this is the line that isn't working.
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_trackPageview']);
//]]>
</script>
It seems the pageview is tracked, the two custom variables, but not the _trackEvent. Like I said in the title, if I copy and paste this code into Chrome Dev Console, the events show up just fine. I added an alert() to the code that returns the _trackPageview and it worked, so the JS is definitely getting parsed.
Any idea what i'm doing wrong?
Thank you
If the opt_value parameter isn't an integer (or undefined), the event won't be recorded.
Do you want this event to affect bounce rate calculations? If so, the opt_noninteraction can be left off since the default value is false:
_gaq.push(['_trackEvent', 'Product Page', 'Added To Basket', 'Bodysuit...']);
If you don't want the event to affect the bounce rate, use:
_gaq.push(['_trackEvent', 'Product Page', 'Added To Basket', 'Bodysuit...', undefined, true]);
I missed this in my first look at your code -- since _trackEvent is before _setAccount, the data it sends get's recorded to a default account (something like 'UA-XXXXX-X').
Move the _trackEvent call anywhere after _setAccount.
Also, since you've got both _trackEvent and _trackPageview in the same block of code, you'll want to be sure that the opt_noninteraction parameter is true.
I have following script in my web site to push a custom variable to Google analytics. But even after 5 days this data is not appear in analytics. Can anyone notice something that I'm doing wrong here?
<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
(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';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'xxxxxxxxxx']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, 'Product SKU','Test Data', 3]);
//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->
Additional info : This script is from Google Analytis module for Magento, I'm over writing the _toHTML method in GA.php
The line that actually sets the custom variable comes after your _trackPageview() call, so the custom variable is never actually sent to the Analytics servers. You need to add either a _trackPageview() or _trackEvent() call after you set your custom variable(s).
_gaq.push(['_setAccount', 'xxxxxxxxxx']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, 'Product SKU','Test Data', 3]);
_gaq.push(['_trackEvent', 'Tow Truck', 'go', '-', 0, true]);
Here's some additional reference material on this: http://www.lunametrics.com/blog/2011/12/30/google-analytics-custom-variables-working/
Event tracking is not working with my Magento 1.5.0.1 CE installation. I have updated the code app/code/local/Mage/GoogleAnalytics/Block/GA.php to:
<!-- BEGIN GOOGLE ANALYTICS CODE v2 -->
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
' . $this->_getPageTrackingCode($accountId) . '
' . $this->_getOrdersTrackingCode() . '
_gaq.push(["_trackPageLoadTime"]);
(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\';
(document.getElementsByTagName(\'head\')[0] || document.getElementsByTagName(\'body\')[0]).appendChild(ga);
})();
//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->';
Then I added an event tracking link to my homepage:
LINK
So I tested this in firefox via firebug and the events are not working. Can someone please help a brother out?
Also the code is being inserted after the opening tag.
This is how it renders:
<!-- BEGIN GOOGLE ANALYTICS CODE v2 -->
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-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';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->
Thanks!
You might not see it in Firebug because it executes so quickly. I would recommend testing via a proxy tool or the Live HTTP Headers plugin. See the tools recommended here.
Your syntax is correct.
Additionally, you may need to add a setTimeout() of 500ms or so to delay the click so that you don't encounter a race condition where the browser goes to that link prior to completing the execution of the tracking call. I have an example of this on a blog post I wrote:
LINK