Google Analytics User Id doesn't take utm_ (acquisition) parameters into account - google-analytics

I have implemented the following process to track User ID on my website:
If the user is not yet logged in, track a pageview
Once he registers or logs in, set user id and keep setting it on every page
I have session unification turned on.
It works OK except that in the "user id" view, I see 100% of acquisition surce/medium as (direct) / (none), but in "all data" though, the utm_ parameters for the same session have been tracked correctly.
I would like to see which campaign was each given user acquired by, but because of this, I am not seeing that.
What am I doing wrong?

Ok, I found the answer in the docs eventually:
Session unification is completed during daily data processing. Processing begins at 5am each day, based on the western most timezone selected in any reporting view that is associated with the property.
Looks like I have everything set up right, just need to wait for the recalculation.

Related

GA4 dimension "Signed in with user ID" disabled

After configure the google analytics property using GA4 instead of UA, I've seen there is something wrong with the user Id dimension.
As you can see in the following image seems like GA4 is not receiving data with the user_id property so it is unable to filter by the property.
By the way I'm referring to this property I'm using a Reporting identity option called By User-ID and device.
Seems like I have something wrong on my configuration, however when I use the DebugView tool of GA4 I can see the user_id is properly sent:
So I'm not sure what's going on here.
Why is Signed in with user ID dimension disabled?
One day after "Signed in with user ID" is enabled without any additional configuration change. So it seems like it just needed some time to fit with data I guess.

Why Google Measurement Protocol is splitting my session before the configured limit?

I'm working on a TV application and I would like to track what people do on it. So I used Google Measurement Protocole to do so. The page and event tracking is working fine because I can see in real time what's is happening on the Analytics 360 website. Everything was ok until I look at the "User explorer" to pick a random user in order to see what he did previously. I found out that he had a lot of sessions in a very short period. So I ran a test for myself yesterday and the result is the same today. I had only 1 session with multiple events for more than an hour and by paying attention to trigger an event before the 30min of inactivity which is configured by default.
Here are examples of data sent :
ds=qml
v=1
tid=UA-XXX-YYY
cd1=local
cm=tv
cid=123456789 (unique id)
uip=XX.XX.XX.XX
ua=SAMSUNG
ul=en
cd=HomePage
dp=HomePage
dt=home
cs=MY_TV_APP
t=event
ec=MY_TV_APP
ea=click on button
el=HomePage
or
ds=qml
v=1
tid=UA-XXX-YYY
cd1=local
cm=tv
cid=123456789 (unique id)
uip=XX.XX.XX.XX
ua=SAMSUNG
ul=en
cd=HomePage
dp=HomePage
dt=home
cs=MY_TV_APP
t=pageview
Here is a screenshot of my session: here
As you can see, there are 7 sessions instead of 1... I don't understand why my session was splitted into 7 parts. I tried to use "sc=start" and "sc=end", the result is the same.
Has anyone ever encountered this problem before?

Mobile data reported in GA Measurement Protocol appear in realtime but not in daily summary

I've been attempting to log activity on a mobile-like device using the Google Analytics Measurement Protocol. All of these attempts have validated using the validation URL, and I can see activity when I look at the real-time reports on the Analytics website. But when I look at the Home or Overview reports for the day - no activity is shown.
The view is set for "All Mobile App Data".
The POST body looks something like this:
v=1&tid=UA-000000000-1&ds=app&qt=1601&uid=uid-zzzzz&t=screenview&cd=Foo&an=Foo%20App%20Name&aid=com.example.foo&aiid=com.example.foo&av=0.0.1&ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36
The ua field is just a pre-defined string. I found that if I omitted it, the Real Time monitoring listed the hits as desktop hits, although I was in a Mobile report and the ds field was "app".
Am I missing a field that is required? Is there some reason why it is showing up in the real-time report, but not in a daily report? Is there some other way to diagnose why the data is vanishing, or confirm the data is actually being captured?
When i check the debug endpoint the hit is valid
Request:
https://www.google-analytics.com/debug/collect?v=1&tid=UA-XXX-1&ds=app&qt=1601&uid=uid-zzzzz&t=screenview&cd=Foo&an=Foo%20App%20Name&aid=com.example.foo&aiid=com.example.foo&av=0.0.1&ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36
Response
{
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026tid=UA-53766825-1\u0026ds=app\u0026qt=1601\u0026uid=uid-zzzzz\u0026t=screenview\u0026cd=Foo\u0026an=Foo%20App%20Name\u0026aid=com.example.foo\u0026aiid=com.example.foo\u0026av=0.0.1\u0026ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
I cannot use one of the mobile libraries from Firebase - this is not one of the platforms they support. I do not wish to pretend this is a web page - there is no associated hostname or path. I do not wish to use Events since I can't do event Behavior Flow, which is one of the things I'm interested in seeing.
I'm aware that it can sometimes take "a day or so" for results to first appear. The site was setup over five days ago at this point, and has received data during that time.
Good thought about the anti-spam setting, however the setting appears to be correct:
I've also tried using GET instead of POST - no change, it still shows the hit in real-time, but then it vanishes.
However, I know that it can record hits permanently. There were two hits from a spammer in Russia that have shown up in the daily report (I wasn't there to see it show up in real-time). I don't know what they did, but would love to find out since it might help figure out how I can add a record.
In the real-time reports, it correctly points out the data center all the hits are coming from. Perhaps that is filtering it out somewhere out of my control?
Try adding Cid I know it says this is an optional parameter but for mobile accounts I belive it may be required.
Client ID
Optional.
This field is required if User ID (uid) is not specified in the request. This anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt.
Example value: 35009a79-1a05-49d7-b876-2b884d0f825b
Although this says it needs to be a UUIDv4, it does work with other UUIDs (I've tested it with a v5, which is a hash against the value used for the uid parameter).

Measuring Page Load Time of single-page app with GA

I'm using Google Analytics in an SPA. For any virtual page redirects (like an AJAX call to refresh the body of the page), I'm getting a page load time of 0ms. Is there a way to track how long that takes, just as if it was a full page refresh? I'm hoping to include how long it takes for the AJAX call and also the time to download and display images that are loaded as a result.
As you have found, Google Analytics will not provide page timings for SPA's. This includes if you increase the site speed sample rate to 100. This is because Google Analytics calculate the page timings using the Navigation Timing API.
For example, DOM loaded would be:
$(document).ready(console.log((Date.now() -
performance.timing.domComplete)/1000))
To over come this problem, you will need to use custom metrics. The solution has three steps.
1) Set up a custom metric in GA.
Go to Admin > Property > Custom Definitions > Custom Metric.
Create a new Custom Metric, with the scope of Hit and the formatting type of time. Note: Specify time in seconds, but it appears as hh:mm:ss in your reports.
2) Set up a timer.
You will need to capture the time when you want to start the measurement of page load time.
An example solution to this might be by decorating all of your internal links, e.g:
$('a[href*="stackoverflow"]').click(function(){
time1 = Date.now()
})
3) Send the time eclipsed (in sec) to Google Analytics on the virtual pageview event.
When the virtual pageview event occurs (which triggers your virtual pageviews), retrieve the difference between the current time (Date.now()) and the time which the timer was started (time1).
Using Google Tag Manager, a custom javascript variable can be created as below:
function(){
return (Date.now() - time1)/1000
}
This value then needs to be sent with the pageview, against the custom metric index set up in step1.
ga('send', 'pageview', {
'metricX': pageLoadSpeed
});
Using the custom metric along with calculated metrics (e.g. {{virtualPageTimings}}/{{pageViews}}, you will be able to calculate your average virtual page timings.
Bonus:
To make the measurement more accurate, set up a secondary custom metric to count the number of virtual pageviews. This will make sure that pageviews which users are directly navigating to are not taken into consideration.
To do this, create a custom metric with the scope hit and the formatting integer.
Then with every virtual pageview, send the value 1 against the custom metric index. E.g:
ga('send', 'pageview', {
'metricX': pageLoadSpeed,
'metricX': 1
});
This allows for the calculated metric:
{{virtualPageTimings}}/{{virtualPageViews}}
If you checkout the Google Analytics docs, you can find out about the siteSpeedSampleRate option, which basically allows you to turn on your site tracking beacons for a percentage of your users.
By default this value is at 1, but I'm assuming you might want to turn it to 100. It might affect a bit in term of network usage since it will have to transfer more data to GA, so take that into account depending on your users and how they access your website (through mobile, bad coverage in some countries...).
You'll have to modify your tracking code to integrate something like the following:
ga('create', 'UA-XXXX-Y', { siteSpeedSampleRate: 10 })
You can send the timing manually, As everything on Google Analytics. But it's a little bit tricky to do,if I'm honest I would no do it unleast it's necessary. All the data on the time report are based on a hit called timing, this hit is send after the pageView and contains the following information.
If you can see my example, I forced the tool to send the hit, just after the pageview goes another hit with a special list of parameters.
plt : Specifies the time it took for a page to load. The value is in milliseconds.
pdt : Specifies the time it took for the page to be downloaded. The value is in milliseconds.
dns : Specifies the time it took to do a DNS lookup.The value is in milliseconds.
rrt : Specifies the time it took for any redirects to happen. The value is in milliseconds.
srt : Specifies the time it took for the server to respond after the connect time. The value is in milliseconds.
tcp : Specifies the time it took for a TCP connection to be made. The value is in milliseconds.
dit : Used to send a random number in GET requests to ensure browsers and proxies don't cache hits. It should be sent as the final parameter of the request since we've seen some 3rd party internet filtering software add additional parameters to HTTP requests incorrectly. This value is not used in reporting.
clt : pecifies the time it took for the DOMContentLoaded Event to fire. The value is in milliseconds.
More info of this parameters on : https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters and
You can see more info of this hit on
https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings
So what happens now?, if I launch another pageview in this SPA, the second pageview on the same page will not carry this hit and you will ever get 0 of loadtime. You can use the command as the official documentation but if you use it you will notice that is not the same hit (i have to double check that). Other option is send it manually using the command 'send' and attaching the desire information. Check your pageview hit structure to be sure that your timming is actually attaching to your previous hit.
The comand to send the timming after the pageview is send will be something like that, use the &dl parameter or 'dp' parameter to attach the timming to the ajax page.
ga('send', {
hitType: 'timing',
'&plt': 1,
'&pdt': 1,
'&dns': 1,
'&rrt': 1,
'&srt': 1,
'&dit': 1,
'&clt': 1,
'&dl': 'http://cl.edreams.com/',
});
Now all the values '1' needs to be updated for the correct one, now how to determine the time of each parameter not sure at all. Also remember that the sampling by default is only for the 1% of the sessions, send this hit only in a few cases.
Disclaimer : This is a very experimental implementation, we are forcing the Js to send unexpected information. Test it well before to pass it to a final project
Greetings

Can I manually tell google the gclid?

Here's the scenario: visitor 1 (V1) clicks on an ad and gets a gclid as part of their __utmz cookie. V1 passes the url to visitor 2 (V2) on another computer. V2 visits the page from the specified url and therefore does not get a gclid. V2 completes the conversion, but adwords does not record the conversion as there is no gclid for V2.
If I can track all the above with some confidence, can I send the gclid from V1 to google when V2 completes their conversion?
Can I overwrite the __utmz cookie or can I add any javascript prior to the adwords conversion tracking script?
If I understand correctly, what you are trying to do is to maintain the campaign information if the user that was exposed to the ad sends the link to someone else. This is a major problem with user tracking in general and I see couple of methods that could help you to circumvent that.
First, gclid is used for adwords tracking. Theoretically you can save it in a cookie and then push it as a parameter to every URL that V1 is visiting and this way to maintain the campaign information when she shares the URL. This is possible, but the downside is that the data will appear as a new session of V1, not a new visitor (V2). From Google documentation:
...User A then copies this URL (containing the auto-tagging parameter)
and posts it in another location such as a public discussion board
(forum) or a social network, or sends it in an email or chat window to
other recipients.
Next, User B clicks this link (containing the gclid value) and arrives
at your website. Even though User B has never been to the website
before, this user will have the first session attributed to the same
click id (gclid) value that was assigned to the original User A. In
this case, you see new sessions (caused by User B) from an old
campaign.
Unfortunately there is no workaround to this scenario at the moment.
(source: https://support.google.com/analytics/answer/4588454?hl=en)
The downside however is that you fix a solution only for Google Adwords, while you may have campaigns on different platforms and sites that do not employ the gclid, but for which you use the UTM parameters.
Another solution I've stumble upon in the past is this one: http://www.lunametrics.com/blog/2013/10/02/direct-monster-fix-dark-social/ This script adds a unique query string parameter to every URL. If this URL is shared, in your GA reports it will show data in a custom dimension that denotes the user that shared the URL (V1) and those that used that URL (V2). This way you can analyze the "power of sharing". The downside is that you don't see the conversion under the campaign in question on GA. Never tried this script, only read about it.
Finally, you can make your own cookie and store the campaign information there. Then, you can append it with a parameter to every page that V1 views on your site. If V1 shares it, the campaign information will pass with this parameter to V2. The downside is that you will not see the conversion under the campaign in question on GA, only the parameter. However, you can see in your conversions report how many of campaign-->referral conversions you had by looking at the URL that led to the conversions (in the Reverse Goal Path, for instance). In addition, you are able to track this way not only Adwords campaigns with referrals, but any campaign. Try this project: https://github.com/dm-guy/utm-alternative. This project will help you with creating your own campaign tracking, but not with pushing it to the URL.
I work on AdWords conversion tracking. Here's how I'd do it using AdWords Conversion Import...
If the GCLID is passed in the URL to V2, then the site can grab the GCLID for V2's visit and store it in a cookie (provided you craft some JS to do so).
Then, when the conversion occurs, you've got another bit of JS that collects the cookie and stores it somewhere along with the date/time of the conversion and the type of conversion (this type should match an equivalent conversion type that you've defined in your AdWords account).
Once you have this process in place, you can batch the conversion records up daily and import it into AdWords via the conversion import service (https://support.google.com/adwords/answer/2998031).
The gclid value pertains to Adwords and Adwords only. To give credit to the converting gclid, you need to send the _ga cookie value in the URL query as such:
foo.com?_ga=1.2.xxxxxxxx.xxxxxxxxx
The x's above represent the clientID and this value needs to be cookied using JS:
<script>
function() {
var coo = window.location.href.split("_ga=")[1].split('.');
var cid = coo[2]+"."+coo[3];
return cid;
}
</script>
Have this above the UA tracking code:
<script>
ga('create', 'UA-xxxxxx-xx', {'clientId' : '<?php echo implode(".",array_slice(explode(".", $_GET["_ga"]), -2, 2)); ?>'});
</script>
Remember you must return the _ga cookie value in the URL in order for it fire off on this page. What's clever is, if you can record to a database IP and the associated _ga cookie value, you can track a user across different browsers and/or devices PROVIDED they are using the same IP address.

Resources