I'm sending hits to my GA Property tracking ID, but it is always going to the first property (UA-nnnnnn-1) instead of the hit going to the tracking ID for the specific property I specified (UI-nnnnnnn-3).
Is it possible to send it to a specific property within an account?
Note: I'm testing out with Real Time.
Here is code:
console.log("Set up Google Analytics: AnalyticsId =", googleAnalyticsId)
ga('create', googleAnalyticsId, 'auto', {
'storage': 'none',
'clientId': sha
});
...
ga('send', 'pageview', '/test');
The hit is going to a different ID (UA-nnnnnn-1) than specified and seen in my console.log statement (UA-nnnnnn-3).
Related
I sent eventValue to Google Analytics. Is there anyway to show that in Realtime ??
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject])
ref : https://developers.google.com/analytics/devguides/collection/analyticsjs/events
No. You have obviously already checked the interface, and for the API the list of available dimensions and metrics does not include the event value.
I have inherited a site which has two GA-UA codes.
These are setup like this
// first code
ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('send', 'pageview');
//second code
ga('create', 'UA-XXXXXXXX-1', {'name':'second'});
ga('second.send', 'pageview');
I have no idea why they are setup like this and indeed do not understand the syntax of the second tracking code
The following can be observed
THE FIRST CODE
Custom events working and being successfully collected
Linked successfully to Adwords
Only has a few months of data and therefore we don't want to use this
THE SECOND CODE
Does not record custom events
Can't link to Adwords
Has years of data attached to it that we want to use
The plan is to just use the second code
For complete brevity custom events are being triggered like this
ga('send', 'event', 'Contact', 'contact-form', 'Goals');
My questions is this
"Because it has lots of historical data we wish to use code two but it is not collecting custom events. How do I get the second code to collect custom events so we can retire the first code? "
If you use two trackers on one site you need to give a name to at least one of them, else the first tracker is overwritten when the second one is initialized.
Thus the syntax for your second piece of tracking code - when the tracker is initialized it is assigned a name, in your example "second".
If you want to send data to that tracker you need to prepend the assigned tracker name to the send call, in your example:
ga('second.send', 'event', 'Contact', 'contact-form', 'Goals');
That is why the second tracker does not receive your event tracking calls, they are only being sent to the first "unnamed" tracker (actually if a tracker name is not assigned it defaults to t0).
Also do not think you can link an Adwords account to two different Google Analytics accounts, so. you'd need to unlink the first account and then link the second one.
I am trying to read the value of a variable in an HTML page, and report it to Google Analytics.
The line in question is this:
<h1 id="results-heading">Your search for <span class="query"></span> returned <span class="total-results"></span> result(s).</h1>
I want to capture the value of the "query" variable.
TIA!
retrieving the query value
Assuming you are using jQuery, you can get the text present inside the span.query using this:
var queryValue = $('span.query').text()
sending to Google analytics
Then you may send this information to Google Analytics using one of the supported mechanisms that is the most appropriate to your use case (which is not described in the question). Examples of how this may be done:
event
ga('send', {
hitType: 'event',
eventCategory: 'you-know',
eventAction: 'whatever',
eventLabel: queryValue
});
(cf. event tracking).
custom dimension
ga('set', 'dimension1', queryValue);
(cf custom dimensions and metrics).
I'd like to send some custom dimensions back to GA with every blog post that is read on my website - author and category.
When I set up the custom dimensions in GA I got this code to use:
var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension2', dimensionValue);
However, in the GA docs it specifies a different syntax using "send" rather than "set".
https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
ga('send', 'pageview', { 'dimension4': '<?=$categories?>'});
We are using universal google analytics, but this conflicting information means I'm not sure which syntax to use.
Thanks in advance
The first code block is how you set the custom dimension (CD) that can be sent with any hit: event, pageview, transaction, etc.
The second code block is how you set the CD and send it with a pageview. So it's a specific example of the first method.
Both are valid, it's just that the second example is more complete.
When sending data to CDs, don't forget to create and define them in the GA configuration as well.
Recently we update our system to work with google analytics universal. We migrated the property to use universal analytics, and a few days later, we made the code changes according to the guide: https://developers.google.com/analytics/devguides/collection/upgrade/guide
We made the change to also use the User-ID functionality. Every event or page view is tracked normally, but the goals completions (which are in the end when a user reaches a specific page).
We introduced the user-id on the midday of the August 6th, and as you can see, the day after the goals were 0 (although because of our database, I can tell was about 25). Day after (8th), the goals (as said before, pageviews with the user-id set) were tracked normally again. Day 9th only a few (and were much more). From that day on, not at all are tracked.
In the beginning I believed that it takes longer to analytics to put the data together because of the user-id, but it seems to me very strange.
The code i am using is:
<!-- Google Analytics Universal-->
<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-xxxxxxx-y', {
'cookieDomain': 'xxxxxxx.xx',
'siteSpeedSampleRate': 25
});
{% if userId is set %}
ga('set', '&uid', userId);
{% endif %}
ga('send', 'pageview');
Everything pretty straightforward, and I am also using the google analytics debug tool to check if all the data is sent, and yes, it's sent. In addition to that, if I reach a page that tracks a goal myself, I can see my session in the real time, so data is sent to analytics.
That's why I am thinking that I am missing some configuration from the google analytics side. I already created a user-id view and the data there contains the same information, but only from 6th august, when user-id functionality was started to be used.
Anyone has an idea or has the same trouble?
Thanks!
If you're using a debug tool and have verified that the user ID is in fact being sent as part of the hit to Google Analytics, then that means you're doing everything correctly on your end.
I copied your exact code, replaced the userId variable with the string 'foobar', and I was also able to verify that the hit was sent correctly, including the string 'foobar'. Here's what it looked like:
http://www.google-analytics.com/collect?
v=1&
_v=j25&
a=1335799492&
t=pageview&
_s=1&
dl=http%3A%2F%2Flocalhost%2Ftest.html&
ul=en-us&
de=UTF-8&
sd=24-bit&
sr=2560x1440&
vp=1605x611&
je=1&
fl=14.0%20r0&
_u=cACAAET~&
cid=2022234602.1393626891&
uid=foobar&
tid=UA-XXXX-Y&
z=304825725
If the data is not properly showing up in your reports, and you're sure that everything is set up correctly for your userId-enabled view, then it could be a bug, and if so, the best thing to do is simply report it to Google.
The best place to report the bug is here:
https://code.google.com/p/analytics-issues/issues/entry
UPDATE (08/26/2014)
It looks like there's already a bug entered for this issue. You can star it here to be notified of fixes/updates: https://code.google.com/p/analytics-issues/issues/detail?id=477
ga('set', '&uid', userId);
Is that printing a literal userId or does that actually work? Try:
ga('set', '&uid', '{%=escape(userId)%}');
have you tried? ga('create', 'UA-XXXX-Y', { 'userId': 'USER_ID' });
information directly from the documentation found at User_id