Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google universal analytics events sent but not received by analytics

I am using google universal analytics on my website. Although POST requests seem to be sent correctly there are no tracked events in my analytics account.

This is the post request (url and analytics id are masked)

Request URL:http://www.google-analytics.com/collect
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:120
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Host:www.google-analytics.com
Origin:http://www.xxxxxxxx.com
Referer:http://www.xxxxxxxx.com/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
Form Dataview sourceview URL encoded
v:1
tid:UA-xxxxxxxxx-1
cid:3E1FA9FE-28B3-7032-1714-5083DD155FCF
t:click
ec:link
ea:outbound_link
el:startpage
ev:headline
Response Headersview source
Access-Control-Allow-Origin:*
Cache-Control:private, no-cache, no-cache=Set-Cookie, proxy-revalidate
Connection:keep-alive
Content-Length:35
Content-Type:image/gif
Date:Fri, 10 May 2013 13:25:44 GMT
Expires:Mon, 07 Aug 1995 23:30:00 GMT
Last-Modified:Sun, 17 May 1998 03:00:00 GMT
Pragma:no-cache
Server:GFE/2.0
Via:1.0 non_disclosed:3128 (squid)
X-Cache:MISS from non_disclosed
X-Cache-Lookup:MISS from non_disclosed:3128
X-Content-Type-Options:nosniff

Does anyone have a clue what's going on here? Thanks!

Jesse

UPDATE

I was trying to send the request via jquery's $.post method first. You can see the result above. Nothing has been tracked by Google Analytics.

Now I switched to this method as described in the analytics.js developer guide

function trackOutboundLink(link, event_hittype, event_category, event_action, event_value) {
ga('send', event_hittype, {
    'clientId' : clientId,
    'eventCategory' : event_category,
    'eventAction' : event_action,
    'eventLabel' : link.href,
    'eventValue' : event_value,
    'hitCallback' : function () {
        // document.location = link.href;
    }
});

    window.open(
        link.href,
        '_blank'
    );
}

The generated request looks like this:

Request URL:http://www.google-analytics.com/collect?v=1&_v=j8&a=217518556&t=event&dl=http%3A%2F%2Fwww.mywebsite.de%2F&ul=de&de=UTF-8&dt=Foosd=24-bit&sr=1440x900&vp=1439x747&je=1&fl=11.7%20r700&ec=OutboundLinkClick&ea=Startpage&el=http%3A%2F%2Ftest.de&ev=Headline&_u=OCC~&cid=283560406.1367606414&tid=UA-XXXXXXXX-1&z=496696042
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Host:www.google-analytics.com
Referer:http://www.mywebsite.de/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
Query String Parametersview sourceview URL encoded
v:1
_v:j8
a:217518556
t:event
dl:http://www.mywebsite.de/
ul:de
de:UTF-8
dt:Foo
sd:24-bit
sr:1440x900
vp:1439x747
je:1
fl:11.7 r700
ec:OutboundLinkClick
ea:Startpage
el:http://test.de
ev:Headline
_u:OCC~
cid:283560406.1367606414
tid:UA-XXXXXXXX-1
z:496696042
Response Headersview source
Access-Control-Allow-Origin:*
Age:120360
Cache-Control:private, no-cache, no-cache=Set-Cookie, proxy-revalidate
Content-Length:35
Content-Type:image/gif
Date:Thu, 16 May 2013 00:10:08 GMT
Expires:Mon, 07 Aug 1995 23:30:00 GMT
Last-Modified:Sun, 17 May 1998 03:00:00 GMT
Pragma:no-cache
Server:GFE/2.0
X-Content-Type-Options:nosniff

Event is fired correctly while the target link is opened in a new window. Status is 200 for the request.

Guess what, I do not get any events tracked in google Analytics. I double-checked the UA code and I cannot imagine any filter in analytics because I did not set one up.

This method is online since yesterday (24 hours). I don't know what's the problem here.

like image 490
Jesse Avatar asked May 10 '13 13:05

Jesse


2 Answers

One thing I do see that's off is t:click. If it were an event it would show t:event

https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#event

like image 97
Crayon Violent Avatar answered Oct 06 '22 00:10

Crayon Violent


Ok, here we go. It seems as if the problem was piping the event through another method.

I finally managed to make it work with this setup:

<head>
    ...
    <script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

        ga('create', 'UA-XXXXXXXX-1', 'mydomain.com');
        ga('send', 'pageview');
        var clientId = '';
        ga(function (tracker) {
            clientId = tracker.get('clientId');
        });
    </script>
</head>

and then in the view

<a href="http://www.outboundwebsite.com" onClick="ga('send', 'event', 'outbound_startpage', 'click', 'headline')" target="_blank">Outbound headline link on my startpage</a>

All relevant data including unique user id is applied to the event and fired correctly. You can see data flowing in immediately when looking at the realtime event view in google analytics.

Thanks for your help guys.

By the way: There is a nice tutorial over at http://blog.kissmetrics.com/universal-analytics

like image 25
Jesse Avatar answered Oct 05 '22 23:10

Jesse