I am trying to confirm a 'pageview' is being processed properly.
( using google real time dashboard ).
The issue is simple, If I use this call:
// page uri is: www.example.com/signup
ga( 'send', 'pageview' );
I see a matching entry at google's dashboard.
Attempting to override the title / page parameters ( according to the docs ) like so:
ga( 'send', 'pageview', {
'page': '/admin/logout',
'title': "test"
} );
Simply produces nothing over at google's side.
Any idea what is going on?
EDIT
It appears that google analytics service is filtering pages that contain
the word "admin".
Removing that from the 'page' helped in my case.
I don't know what's going on because your syntax is definitely correct.
FWIW, while the real time dashboard is a great way to see your hits come in, it should not be considered proof or evidence that something is or isn't working. Everything you send to Google Analytics goes through processing after it comes in, and (for a variety of reasons) a hit may be dropped from reports after showing up successfully in the real time view.
There's also always the possibility that there's a bug in the real time dashboard, and a particular hit may not show up even though it will ultimately make it into your Google Analytics reports.
A much more reliable way to see if your code is working is to take a look at the data that is actually being sent from your page. You can do this via the network inspector (in Chrome) or by using the debug version of analytics.js, which logs status and error message to the console.
Related
I've got myself a bit of a head scratcher here, for me anyway, as I'm a bit new to all this.
I have WP a site that has its GA snippet inserted with Google Site Kit.
There is a plugin that, when a user registers, sets the users ID to a custom dimension.
The code to execute this 'set' has been added to the WP footer with the add_action('wp_footer') command.
The code looks like this:
<script type=\"text/javascript\" id=\"set-google-id-dimension\">
document.addEventListener(\"readystatechange\", event => {
if (event.target.readyState === \"complete\") {
try{
gtag('event', 'registration', {'dimension1': '".$client."'});
}catch(e){
try{
ga(function() {
// Logs an array of all tracker objects
var trackers = ga.getAll();
var firstTracker = trackers[0];
console.log('tracker: '+firstTracker.get('name'));
ga(firstTracker.get('name')+\".set\",\"dimension1\" ,\"".$client."\");
});
}catch(e){
console.log('GA and GTAG not defined');
}
}
}
});
</script>
For ease of reading, I've stripped out the PHP, but this is being echoed out in the footer.
Why the GTAG and GA command? Both analytics are being output in the console, though the site owner does not know why as "they only use Google Site Kit".
Now, this code works on the dev site that I control (and I've set it up to mimic the live site as best as possible):
However, when on the "live" site, the dimension is never set, even though I can see the 'set' command being executed (ignore the timestamps in the console, I forgot to screenshot before navigating away from the site and had to go back and reload the page):
The live site does not use the default tracker, hence the ga.getAll() call to access the tracker information.
From what I can see, everything should work fine.
I understand that from reviewing this question
Google Analytics Custom Dimension Not Being Set
that the 'set' needs to come before the 'send'.
I'm not sure how to accomplish this though since the plugin does not send the pageview to GA, from what I understand, that's Google Site Kit. I have contemplated adding a 2nd pageview send when this plugins code is loaded (it is only executed immediately after a registration and never again), but that would skew the page hits.
This site has had a myriad of "admins" over the years, so I wouldn't be surprised if there was something buried in one of the plugins causing a conflict somewhere. At one point I thought it was a timing issue, so I had the function load every 50 milliseconds checking for 'ga' to be defined, then execute the 'set' command (with a limit to 35 iterations), but the issue was the same (could set the command execute in the console, but the dimension did not reflect the value).
Any advice I can get to debug and get to the root cause would be of great assistance to me. Please ask any questions you need and I will respond as quickly as possible.
It seems a bit complex as a situation so understanding how it works and why there is gtag and ga at the same time is not easy to understand.
In any case, assuming that everything is working, what you can do is not to send a second pageview but send a dedicated event (by setting non-interaction to true) in this way you do not alter any information in Google Analytics and you can pass to the platform the data you are interested in (dimension1).
Looking more for some fresh ideas to help me troubleshoot the below problem than solving any coding issues (which may come next).
Creating a similar site to an existing one that uses all previous GA tech (analytics.js, _gaq.push, Google_Service_AnalyticsReporting_ReportRequest(), etc) and provides all the easy data needed for my simple GA reports (i.e. page views by date and location).
However, not quite ready to bite off the whole enchilada (GTAGMgr, GA4, and such) so created dual Properties (UA and GA) as many forums have recommended when making the transition.
Setup the website same as the active [UA] site but using the gtag.js (per the Property Tracking Code snippet provided in ADMIN) vs the analytics.js code. Created View(s), new Service Account for the "user", an API Map Key for the Google Map Charts, and any other pieces I could find.
Have the GTAG.JS setup on each page and added any special page tracking via gtag('event', 'page view', {...}) but letting the default page view still occur as well.
Page view hits are coming through as expected EXCEPT the page views locations (City, State, Country, Region) are not being populated. All that comes thru is the "not set" for any location. Ironically, the old analytics.js code was still active initially and location data was being populated.
Would think if gtag.js is collecting standard page view info for the configured Property, that location data would be there as well. Am sure it is but possibly the older getReport calls need tweaking. No doubt I probably have a something not quite right but if REALTIME data shows usage, page views, etc. AND my GA Report calls are working, would think location data would be there too.
Any brainstorming ideas would be appreciated.
Thank you,
LarryG
ANSWER ... the EZ Button ... my code and calls were correct using old and [semi] new way. The majority of the problems were McAfee VPN kicking in. It is set to turn on with reboot and I do not always remember to turn it off. The first obvious clue was the realtime location for my actions were not where they were supposed to be. Also, appears Google API PHP Client has some issues with PHP7.4FastCGI.
So if you took the time to read ... check your VPN settings if you are getting an abnormal amount of NOT SETS in your GA data.
Begs the question ... with the increase in companies providing VPN services out of the box, that renders some of the tracking a moot point.
LarryG
I've got an email campaign that Im trying to track with Google Analytics, but for some reason the source, campaign etc are not being tracked.
The URL I'm using is:
https://makemeacocktail.com/list/14911/wimbledon-cocktails/?utm_source=mailinglist&utm_campaign=weeklynewsletter&utm_term=wimbledon
I've obviously got some htaccess rules kicking in that change the php _GET variables, but that shouldn't really matter here (I dont think).
My GA tracking code is:
const dimensions = {
TRACKING_VERSION: 'dimension1',
CLIENT_ID: 'dimension2',
};
const TRACKING_VERSION = '1';
ga('create', 'UA-22275118-1', 'auto');
ga('set', 'transport', 'beacon');
ga('set', dimensions.TRACKING_VERSION, TRACKING_VERSION);
ga('send', 'pageview');
ga((tracker) => {
var clientId = tracker.get('clientId');
tracker.set(dimensions.CLIENT_ID, clientId);
});
and passing the GA script through using:
<script async src="https://www.google-analytics.com/analytics.js"></script>
(This can all be seen in the source). Am I doing something fundamentally wrong?
Thanks in advance
Here are a few thoughts to troubleshoot this:
Install the Google Analytics Debugger in Chrome and verify your pageview is triggering when the campaign URL is there. You'll be able to see individual dimensions and metrics too (so you can check you custom dimensions too).
It seems like you're implying that the pageviews are working, but I wanted to include this just for due diligence.
Looks like you're relying on ES6 and the beacon to send data. That should be fine, but if your users are on older browsers that may prevent the data from coming through.
UTM campaigns require a utm_campaign, utm_source, and utm_medium to be valid. This does not prevent them from sending, but I'd recommend updating your campaign URLs if possible (you're missing utm_medium).
Are you using a filtered view? If so, your own traffic won't appear in the reports.
Are you using the Real Time reports? If not, you'll need to wait a few hours before the data becomes available in the Google Analytics standard reports.
Hopefully one of those steps gets you pointed in the right direction. Best of luck!
Edit: Viewing the source of that link you provided, I don't see your Google Analytics snippet in there. Maybe you're working on it now, but try viewing the page in an incognito window and check the source (maybe your script is tied to an admin or dev user?).
I've been all over google and SO looking for answers here. I've checked code against google's tracking code suggestions and I've even tested with their sample code. But I cannot get the events to be properly tracked in Google Analytics. My code has been live on the site for some time (~ a month), so this should have overcome any lag on the reports there.
I'm using analytics, the async version, which works fine for page tracking and other 'normal' features. Trying to set up event tracking, I followed the example, and waited a week. Still nothing. I've been debugging and I'm not having any of the 'normal' problems (as far as I can see).
So:
Example tracking code fired:
Play
This triggers an event, which according to ga_debug.js, is fired successfully. Checking the network panel I can see the request and _umt.gif returns status 200.
I've checked the request string in there. All seems good.
But checking GA, there is nothing in the reports. But when you go to GA Realtime > Events, you can see the events being fired!?
I can trigger the events on page or fire them from the console and corresponding events show up in the realtime section, but they have no data (Category, Action or Label).
This is odd, that even firing Google's own example code nothing is showing up.
If anyone has any ideas of where to start debugging for this (or has experience of anything similar), it would be great to hear.
I have been struggling with this issue for three days. I know this thread is old, but I stumbled upon it during my searching. I wanted to post what my personal resolution was in case someone else comes across this.
My Solution:
Here is where I finally found it:
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables
Under: "Using Custom Variables" > "Traditional (ga.js) Snippet" (We are using the ga.js still... for now.)
I had a similar problem and ran into this issue:
https://issuetracker.google.com/issues/35353093
In summary, I was setting the userId property via below. Removing that started historical tracking for me.
ga('set', 'userId', username);
This question gets asked a lot and the answer is almost always "Google Analytics standard SLA is 24 hours". The logs are processed in batch behind the scenes. At peak times, this takes a while.
It can take up to 24 hours for the Google Analytics servers to update -- Source: Google Documentation - Check your web tracking code setup
I have correctly included the GA tracking code snippet found here (http://support.google.com/analytics/bin/answer.py?hl=en&answer=1008080&rd=1) and it is working (& has been for years)
I have recently set up the Facebook Javascript SDK for running code when the 'like' button is clicked - this also works.
In the same FB.Event function, I included googles _gaq.push _trackSocial as follows...
FB.Event.subscribe('edge.create',
function(response) {
// do some stuff, this is working.
// google track likes - this isn't working
_gaq.push(['_trackSocial', 'facebook', 'like']);
}
);
No errors in console.
So either analytics takes a long time to register the likes & I haven't waited long enough or something is wrong.
Since the FB.Event & my JS functions ARE WORKING & _gaq.push does not give any errors - I am unsure what the problem is.
In Google Analytics Traffic Source > Social > Social Plugins then click on the 'Social Source' tab & it shows only Google.
24 hours later the answer is evidently that Analytics takes a long time to update.
Although I have not changed anything Analytics is now showing Facebook as a Social Plugin.
So it just takes a really long time to show up in analytics.
If you're using the 'newer' analytics.js vs the legacy ga.js version you need to use ga('send'...) instead of _gat.push(...).
I would have expected you to get an error in your situation, but this may help others.
ga or _gaq.push for Google Analytics event tracking?
If you're trying for instance to use the social-tracking.js from StuffedWeb alongside analytics.js then you'll need to convert it to the new call style.