How to correctly use google analytics measurement protocol? - google-analytics

I'm learning to use google analytics for apps. For test purpose i have created a new google account, enabled analytics for apps and issued following command from terminal to test is it working:
curl "http://www.google-analytics.com/collect?v=1&tid=UA-12345678-1&cid=123&an=myapp&t=event&ec=action&ea=click"
Unfortunately, this request don't affect any numbers i see on analytics page - it's all zeroes. Any request to google analytics results in "200 OK" and 1x1 pixel gif image, so i can't figure out the problem: is the request incorrect, or i need to somehow preconfigure google analytics, or it have days delay before data is displayed etc.
Any suggestions?

It looks like your issue was solved. Some pointers for other people coming to this page:
Look in realtime reports.
Try to send pageview or screenview instead of event. They show up in more places.
The cid should be a UUID v4.

For debuging your requests you can use this URL:
/debug/collect
instead of
/collect
In response body you will see details.

Related

Is there any API call or any kind of feedback to know whether data is actually sent through google analytics collect endpoint?

I have settled my google tag manager as from the guide.
I have got in place a page that redirect just after the tag gtm-load is collected into the dataLayer. It's actually a "transition" page that should redirect instantaneously.
In this way I make sure google-analytics.com/r/collect is called, as I can see from the network ta of my browser, seems the only way to do so for an "instant redirect page".
However I need to test it from the back-end side.
Is there any way to have a feedback from Google Analytics about the data is actually sent? For example something like google-analytics.com/get/data/lastEntry, so that I can use a restAPI to check it out?
As far as I know, google analytics provide only metrics through a web page, and no actual data sent to.
Moreover there are some Rest API here but they are only for configuration purpose.
you might pass a JavaScript function as a hitCallback parameter of analytics send command and it will be called right after hit data were sent:
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#hitCallback
Here's an example of how to use it with GTM alongside another useful feature of eventcallback
https://www.simoahava.com/gtm-tips/hitcallback-eventcallback/
Hope this helps.
There is a realtime API in Google Analytics, so what I have done for testing is to call my test URL with utm campaign parameters attached. Then I made a call to the realtime API and filtered by my custom campaign.
The realtime API is fairly limited (no session based values, obviously, you cannot test custom dimensions etc), but at least this tells you if your hit has registered in GA.

How can I use Google Analytics without its gtag.js library

I am having some pages where I need to track page views and get data for reports. So I need to use some tracking events without using gtag.js.
I have tried solutions like GIF Request Parameters
But this solution was there in ga.js and its a legacy
The format used in your linked documentation is deprecated since Google introduced Universal Analytics in 2012.
However the current solution to send requests to Googke Analytics without a library, the Measurement Protocol, works broadly the same way. You have an endpoint (google-analytics.com/collect) and add the necessary parameters as described in the reference, depending on what kind of interaction you want to track. The endpoint returns a 200 http status and a gif (no matter if the request has actually been logged in analytics, this just confirms that you actually hit the server).

Google Tag fires but not logged in Analytics

I had set up my Google Tag to track clicks on spans with certain IDs, the events are firing according to WASP extension, but they are not showing up in my Google Analytics account.
Here is my trigger:
My Tag:
WASP in action:
GA displays pageview only:
Code is installed properly
Sorry if this seems pretty obvious, but in Real Time you should be on the Events tab, and it seems you are looking in the Content tab. Events are never displayed there.
While the configuration looks to be correct, remember that events won't show up in your standard reports until the data is processed, which takes about 24 hours. As long as the hit is showing up in your Real-Time reports, then you shouldn't have any issues.
Can you please post full HTTP request? For instance from Charles Web Debugging Proxy of Live HTTP Headers extension or anything simillar.
What you post seems to be correct as #nyuen says!

What is utmu parameter in google analytics __utm.gif request?

I am trying to make the google analytic __utm.gif request using php. I have broken all the variables and the only one which I don't know about is utmu parameter. It is not documented anywhere.
When I see a pageview tracking request it is appended to the end of request as &utmu=qB~
While doing ecommerce tracking it is appended as &utmu=qBAL~
Please help me with this.
It is a bitmap of all of the methods used to build the request.
Source: http://glucik.blogspot.com/2011/02/utmu-google-analytics-request-parameter.html
utmu doesn't actually contain anything of external meaning. Google uses it to store some internal values that help them improve ga.js. It's not required to make any functionality work, so, your PHP code doesn't need to account for it.
However, you should know there are already a few long-standing PHP-based Google Analytics projects, like Server Side Google Analytics (SSGA), as well as the semi-official Google Analytics for Mobile PHP and PHPGA.

Is it possible to send data to Google Analytics service by url?

I've been trying to send data to Google Analytics through url, but it's not working.
Here is the url:
http://www.google-analytics.com/__utm.gif?utmac=MY-UA
&utmn=0.57942900+13058623924dd5e0f88d784
&utmp=%2Fmypage.html
&utmr=http%3A%2F%2Fpp.test%2Fmypage-ref.html
&utmdt=test+ga&utmul=en-us
&utmhn=pp.test
&utmcc=__utmz%3D1.1304060743.1.1.utmcsr%3D%28direct%29%7Cutmccn%3D%28direct%29%7Cutmcmd%3D%28none%29%3B+__utma%3D1.100229728.1304060743.1304060743.1304060743.1%3B+__utmz%3D185677488.1304391672.1.1.utmcsr%3D%28direct%29%7Cutmccn%3D%28direct%29%7Cutmcmd%3D%28none%29%3B+__utma%3D185677488.2126025763.1304391672.1304667350.1305106191.6%3B+PHPSESSID%3Dpghin7v4q3g5lssq5c5mjchfj6
&utmcn=1
&utmcr=1
&utmwv=1
&utmsr=1280x1024
&utmsc=32-bit
&utmcs=-
&utmje=0
I have been trying follow the parameter here http://code.google.com/apis/analytics/docs/concepts/gaConceptsOverview.html
I call the url by curl and tested through the address bar, but not working, no data in my Google Analytics :(
Any ideas please?
It's possible, although if you're trying to do it you're probably doing something wrong.
But there's more to it than you can see at first sight. The best way to achieve it is to use a mobile library for Google Analytics. Google already provides this for a couple of languages. These libraries are built to send data to Google Analytics via your server. And if you check the server code you'll see that there are some calculations involved. You can possibly change one of these libraries to be run without a request. They're not complicated.
http://code.google.com/mobile/analytics/docs/web/

Resources