Bridging the gap between _gaq.push and gtag - google-analytics

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

Related

Know what the user does when a specific error happens using Google analytics?

I have a website that sells products and I'm using google analytics to know some statistics about the website. Sometimes, errors happens for various reasons and purchases doesn't go through. You then have to refresh the page and try again, then everything works. The website displays the message telling the user to refresh and try again. I'm curious how many people actually do that. My question is, is it possible to know what users do when this error happens? Do they refresh and try again? Do they close the tab or do they do something else?
The question is quite broad at this moment, but there are a couple of improvements to your measurement setup, that can help you to investigate this customer behavior.
What I would do, is to implement an event tracking to indicate, that this error has occurred. You can find details about event tracking in this guide. Although I suppose, that your users are not likely to enter the website at this page, it might be a good practice to set the non-interaction flag of the event, as it is not actually generated by a user interaction.
I'd also create tracking for page reload, either by creating an other event for this, or by adding -reload suffix to these repeated pageview URLs. You can find good resources for this on SO as well, e.g. this one.
If you have a special URL for this error page (e.g. purchase-error.html instead of purchase-success.html), it is also easy to track the exit rate specific to this page.
Besides of Google Analytics, you might also want to set up heatmap or screen recording tools to understand this behavior. Hotjar, Lucky Orange are a few examples. (No affiliation.)

I'm unable to run experiments accross subdomains using Universal Analytics

I'm currently running an experiment without redirect, using Google Analytics, but I'm running in some issues.
The case
I work for a company that has two websites, with two separate brands, selling the same product. Today, we are plaining a merge of the brands, one of the reasons being the low costs of maintanance.
To see how this would affect sales, we are doing an a/b test. The test consists of changing the logo of the sites, and displaying an information about the merge of brands in the variant. The original is the website without changes.
We have some requirements to do it:
We use a CMS that has no support to the Google Analytics Experiment tag (we get some errors when we install it to the , and are unable to run it)
We need to run it through all pages of our websites. We have also a subdomain in each site, that the user is redirected to place an order.
We doesn't have time to wait for the experiment to end for itself. So, we came up with the idea to track the rejection and sales using a duplicate pageview with "/variant" in the url and in the title.
To do that, I used the Content Experiments without redirects, with the Google Tag Manager.
Configuration of the Experiment
In Google Tag Manager, I load the Content Experiment Javascript API and define the choosenVariation variable in all pages of both websites and subdirectories.
I track the "gtm.load" event, to see when the page finished loading all elements and change the DOM in three ways: changing the logo, adding the content about the merge and add an item to the main menu. All of this, through Javascript.
Along with the changes of the DOM, I add a datalayer called VirtualPageView, and pass the corresponding url with "/variant" and the title with "Variant".
When the datalayer fires, I send a new Pageview with the variant information.
The problem
The experiment is running right, but when a user gets the B variant of the experiment and procceed to a subdomain of our websites to place an order, it seems that it's somehow running another test, and happens to the user get the A variation.
We are trying to persist the original session and the client Id through the domain and subdomain, in order to the user that saw the different logo, continue in his way to order.
I saw this page about Running Experiments across Subdomains, but its about the Classic Analytics and the classic experiment, and we are using the Universal Analytics with the Content Experiment without redirects.
I don't know if my explanation was clear enough, so if someone have doubts, please ask me. I don't have a profound knowledge of Google Analytics or the Content Experiments either. So, if you have a better way to do this, please, tell me.
I came up with a solution to our problem. We agreed to use the experiment only in the pages of the main domain, so I can change the content otherwise in the pages of the subdomain:
When a user visits our main domain, through Google Tag Manager, I created a cookie that says what the result of the variation chosen for the user (0 for the original and 1 for the variation).
When this user goes to our subdomain to place an order, still via GTM I check the cookie to see its value. If its equal to 1 (a variation), I change the logo and the menu, according to our previous configuration, and I send a virtual pageview to help us check the data.
Until now, this is working properly.

Google Analytics reporting data before tag is even up

So I've been working on a website for a while. GA account has been up for a couple months but I waited for the website to be finished before putting up the actual JS tag.
In the meantime, the website is being HTTP password restricted (basic authentication) so it isn't even accessible unless you know the user/pwd combination.
To my surprise, I realized today that GA has logged several hundred views to the root of my website. Paths are mostly things like:
/
/?from=http://social-widget.xyz/
/?from=http://www.traffic2cash.xyz/
Bounce% and exit% both at 100% for all of them.
I realize this looks like referral spam, and there are ways to prevent it. Came across this upon googling:
http://botcrawl.com/block-social-widget-xyz-referral-spam-in-google-analytics/
My question is: how can GA log anything anyway when no tag is up and the website isn't even accessible?
Thank you very much in advance
Because it's spam. They hit Google Analytics directly with random GA codes and don't even go through your website.
GA can't tell if these are real hits (from website visits) or fake hits (from spam bots who hit GA directly calling the same ode as they would if on the website). Though arguably they should do more about this.
Massively annoying - particularly when first starting out as this can be a heavy proportion of your "traffic".
It's easy to set up a filter rule is to catch a lot of this by filtering on hostname. As they are randomly hitting GA and don't even know what website they are hitting GA for, they don't usually set this correctly. Real traffic should only come from yourwebsitedomain.com so add a filter for that.
STRONG piece of advice: abandon the default UA-########-1 tracking code of your new website -- simply do not use it!
Create a second and third property on the Admin screen, then use the tracking code for the third property. You will immediately see a lot less spam. No filters or segments necessary!
If you want the whole sad story about spam visits in GA, I have been maintaining the Definitive Guide article for over a year now:
http://help.analyticsedge.com/spam-filter/definitive-guide-to-removing-google-analytics-spam/

How to use analytics screenviews in a website?

I'd like to track screenviews in my website, is this possible or are screenviews just meant to be used on apps? If so, how can I do it? Let me give you an overview of my situation.
I am restructuring a web site. Some of the pages that used to live under differents urls are now living under the same, with a hash id to denote the particular area of the page the user is in. So, for example, http://www.example.com/topics/topicA, http://www.example.com/problems/topicA and http://www.example.com/equations/topicA, are now in http://www.example.com/topics/topicA#content, http://www.example.com/topics/topicA#problems and http://www.example.com/topics/topicA#equations.
Now, I'd like to keep track of users visiting these areas. My initial idea was send a page view when the url is loaded and send a screenview each time the user clicks on the button to change the area of the page (i.e. #content, #problemas or #equations). For doing so, I used something like ga('send', 'screenview', {'screenName': 'content',});. As I couldn't see the screenviews in reports, I played a bit, setting the app name, the app id, the installer id etc before sending the screenview, for example:
ga('set', {
'appName': 'myAppName',
'appId': 'myAppId',
'appVersion': '1.0',
'appInstallerId': 'myInstallerId'
});
ga('send', 'screenview', {'screenName': 'content',});
So I can't see the screenviews in the real time reports (though I can see the page views). I can't see them in the regular reports either. I decided to create custom reports with dimensions Page and Screen name. There, I see sometimes screenviews are tracked (I think it happens when I set the appid etc before sending it, but not sure about this point).
Are screen views adecuate for tracking this behaviour or should I use just events, as I'm not on an app at all (just a responsive website)?
By the way, I am using Drupal 7 but that shouldn't make a difference.
Thanks in advance for your time and I hope I am making my question clear enhough.
Technically speaking its probably possible to send both pageviews and screenviews to the same Google Analytics web property.
The problem you will have is seeing the information. The way the Website is set up its either application or web account, Screenviews or pageviews. The reports are different, and you cant swap between them.
So you could send screenviews to a web site web property but you would never be able to analyse it on the website you would have to use the API to rip the data out. That and you would be analyzing apples and cars. Screenviews and pageviews are different they cant be analysed together.
Because of this web property's should be kept separate one for application (screenviews) one for web sites (pageviwes).
You should in my opinion do this using events.
+1 for an interesting question that made me think :)
Is possible, actually in BigQuery you can reach both data and see how this interact, both will have the same schema and will be stored in the same dataset(it is linked the raw data view). Even in the same sessions, you can send pageview and screen views having funny results.
But there is some important consideration when you implement this.
You need 2 different views, one Web View and One App View. Both views will let you access to different information and is not possible on the web interface of Google Analytics to access to both info at the same time. Not sure if with the API you can access to both info at the same time, I think that is totally possible
In the App View, you will able to see only information of screenview, events and ecommerce.Is also mandatory the App Name parameter on this hits.
In the Web View, you will able to see only the pageview reports,events and events.
The ecommerce info and events will be reachable from both views, there is no way to know if this comes from a web or an app ( technically). So is tricky to read this kind of reports in that case.
Sessions can experiment stranges behaviors. As example gosht sessions coming from the screen view with no page view, sending events.
Taking this into consideration, as Dalmto says, the best to you is use events or sent virtualpage view.
Mixing pageview and screen view is not recommended by Google but is totally possible.This kind of implementations is only useful when you have an embed web-app and a webpage on the same server and you want to have it all on the same dataset, if this case apply, is highly recommended to add a custom dimension to filter the app info on the web view and the web info on the app view and keep both worlds separated.
As the last point, your code is working, I can see the screen info on the desktop property. But not be able to see it in the web view.

Add Analytics to account of someone other than the one who set it up?

I have been requested to get involved with a family member's site.
To date, they have been paying an SEO outfit, which I believe has been feeding them lies and milking them for money.
I can see that all pages in the site have Google Analytics. However, the SEO outfit refuses to let us see the Analytics page, and has always just forwarded them some (presumably doctored) slideshows.
The only tracking service that lists their site is Compete, which shows a number of visitors far from what they are paying for.
I would like to add their site to my own Analytics account. I have ftp access to their server, and permission from the site owners to modify any files I want.
However, I don't want to do anything that might destroy the entire existing history of analytics data, or even that would interfere with the current SEO outfit [until I have something concrete in-hand].
Does anyone know:
Can I add Analytics to my own account when it was originally setup by someone else?
Will there be any negative results of attempting this?
Any other ideas?
Thanks
Edit: Can anyone suggest a better title - I can tell mine is not good?
I've put two Google Analytics tracking codes from different accounts on the same site without issues. It may cause the site to be a tiny bit slower (as it communicates twice with Google) but it'll do nothing that would delete old data or impede collection of new data.
In short, what you're doing sounds like a good first step.
You will not, however, be able to access past data by doing this. You will be able to compare their numbers with the numbers you're getting, though, which should be valuable.
I don't know if you can add the same domain to two different Google Analytics accounts (easy enough to try, though), but you can always add another service's Javascript snippet, e.g. Woopra. Google and Woopra produced very similiar results in my experiments.
You may want to leave their Google Analytics tracking in place while adding your own Google Analytics tracking. In that case, your numbers should be identical to whatever is being tracked by this third party.
You'll need to set up your own account and then add in the creation of your pagetracker object and your own track page view. You don't need to recreate the entire page code. You can do it with two more lines. It would look something like:
var pageTracker =
_gat.getTracker("UA-XXXXXXXX-1"); //EXISTING pageTracker._trackPageView();
var secondTracker =
_gat.getTracker("UA-XXXXXXXX-1"); //YOUR TRACKING ACCOUNT secondTracker._trackPageView();

Resources