This site is a Wordpress/WooCommerce-page, - so it has many different 'real' URL's.
In my Google Analytics-report, then the numbers under 'Behaviour' >> 'Overview' (and in 'Behaviour' >> 'Site Content' >> 'All Pages' for that matter) is looking wierd. If I have it shown as 'Page' then it bulks all visits that doesn't have a parameter (such as ?s=search_term or ?key=order_number) - and shows them all as visits to /. Example:
But if I click on 'Page title' instead, then the distribution is shown correctly (but I can, for obvious reason, not see the URL, which is annoying):
If I add the secondary dimension 'URL Destination', then it's just shown as not set.
How do I get 'the regular' (The page-view) to work? And why does this occur?
You have mixed syntax for "classic" Google Analytics and Universal Analytics. Also you are overriding the page path.
This is a screenshot from your code (tracking id removed):
This is "old" syntax. This still works and would not per se be a problem if you did not try to call Enhanced E-Ecommerce functions in the code that do not work with classic ga:
This creates a reference error:
The classic code has a variable that is called "ga", but that is not the same as the ga object in Universal Analytics (and also it sits inside a self executing function and is thus not available in the global scope).
The culprit for your page path problem however is this line:
_gaq.push(["_trackPageview", "/"]);
By setting the second argument to "/" you override the current page path and set it to "/" for all your Urls.
You should update your ga code with current Universal analytics code and not set a page path (i.e. do not provide a custom page to the send pageview call):
<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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-X', 'auto');
ga('send', 'pageview');
</script>
Related
New to google analytics so bear with me. I added the event tracking to my code, but when i check in the reporting behavior event tab it's blank. Here is my code.
<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-XXXXXXXXX', 'auto');
ga('send', 'pageview');
</script>
here is an example of my a tag
<a href="http://example.com/" target="_blank" class="app-logo" ga('send', 'event', 'Link', 'Click', 'example.com');>
In google-analytics, for the correct website, look on the "realtime/events" page and see if events are appearing there (they should appear here within a few seconds, after being triggered on your website).
If not, you might have added a filter, to filter out events generated by traffic from your own IP. You can find this filter under "admin" and then "all filters". If so, remove it (or temporarily change the IP-address, so it doesn't match). After that, generate a few events on your website and look again on the google-analytics page, under realtime traffic / events page.
If they work under realtime, it should also work in non-realtime (but it might take 24-48 hours to appear there!)
Not sure if this just a typo in your example, but you are missing the event handler in your link:
The event handler ("onclick") is the bit that specifies which action shall trigger the javascript code. If you just dump the event call in the HTML it will not even be recognized as JS.
I installed Google Analytics (UA) and added tracking code to a html page.
I ran html page from the browser file:///C:/test.html and debugged using google debugger, it ran successfully and shows sent beacon - but Analytics does not show the numbers. I waited for a day but still does not work.
**It works fine if I place the file in c:\Inetpub\wwwwroot and run as http://localhost/test.html
-------------------Code in test.html page-------
<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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-******-*', 'auto',{'storage': 'none'});
ga('set', 'checkProtocolTask', null);
ga('send', 'pageview');
</script>
Can anyone tell me if google analytics works in my case.
What you want to do should definitely work, but you'll have to modify a few other things you're sending to prevent the hit from being dropped by Google Analytics.
Basically what's happening now is your hit is invalid. As you can see here using the Hit Builder tool.
I think you should be able to get around this by using the page field instead of the location field (which is auto-populated by analytics.js when you create the tracker), like so:
ga('set', 'location', null);
ga('set', 'page', '/test.html');
ga('send', 'pageview');
I've never tried this without also setting the location field, so it's possible Google Analytics will still complain that no hostname is present (Note: I tested this with Google Tag Assistant and it did complain, but it didn't say anything about the hit being invalid, so it will probably work fine.)
If using page instead of location doesn't work, you can always just modify location and give it a fake hostname, and that will definitely work.
ga(function(tracker) {
var oldLocation = tracker.get('location');
var newLocation = oldLocation.replace('file:///C:', 'http://fakehostname.com');
tracker.set('location', newLocation);
})
ga('send', 'pageview');
In either case, you won't need to unset the checkProtocolTask because you're now not using the file protocol.
Since it sounds like hostname doesn't matter in your case, giving it a fake value should have no impact on your reports.
I set up some filters in Google Analytics to remove spam referrals. It works great for the majority of the referral links but since last week, three websites are showing up again. What's the reason for this and how to make them disappear again?
Filter 1
darodar\.com|priceg\.com|semalt\.com|buttons\-for\-website\.com|makemoneyonline\.com|blackhatworth\.com|hulfingtonpost\.com|bestwebsitesawards\.com|simple\-share\-buttons\.com
Filter 2
econom\.co|ilovevitaly\.com|ilovevitaly\.ru|humanorightswatch\.org|free\-share\-buttons\.com|buy\-cheap\-online\.info|domination\.ml|mobiletest\.me|site2\.free\-share\-buttons\.com
Filter 3
Get\-Free\-Traffic\-Now\.com|googlsucks\.com|theguardlan\.com|quirktools\.com|guardlink\.org|site3\.free\-share\-buttons\.com|site4\.free\-share\-buttons\.com
Filter 4
Site5\.free\-share\-buttons\.com|site6\.free\-share\-buttons\.com|event\-tracking\.com|free\-social\-buttons\.com
The following three referrers show up again in Google Analytics.
www.Get-Free-Traffic-Now.com (Filter 3)
free-social-buttons.com (Filter 4)
www.event-tracking.com (Filter 4)
EDIT:
Someone marked this as a possible duplicate of this question but that's not correct. The answer there suggests using filters but that's exactly what I've been doing for the last couple of months. Someone else suggested looking for fake hostnames but I only see the valid one so nothing to block there.
The method I found the best was to use custom dimension as the filter.
The "spam" is not spam on your page, it's only your GA-code that is used on a different page.
Since the "spam" is never on your page they can't know what dimension or how to use it.
So..
In your Javascript code add a dimension like:
<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', XXXXXXX, 'auto');
ga('send', 'pageview', {
'dimension1': 'true'
});
</script>
This sends a custom dimension with the value "true".
In Analytics you add it to the Custom Definitions -> Custom Dimensions.
Then in filtering you INCLUDE on this custom dimension if it contains "true" value.
So only data with a Custom Dimension1 with value "true" is counted. If the spammers finds this out.
Then they are good :-)
This way you will only get true data on Google Analytics and no strange referals.
I have had this running for about a year on my page now and have no strange referals anymore.
All referals I have in GA is true referals.
I am trying to configure my blog and the analytics code for it. There are multiple authors in my blog. What I am trying to do is aggregate the number of views by separate authors.
This is what I did
Went to my Analytics Admin and from there, for my Web Property I created a Custom Dimension from Custom Definitions.
The custom dimension is creted with Index 1 and the scope is "Hit". It is shown in the image above.
Then for the analytics code, that I place in the posts of my Blog, I placed the following code:
<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-XX', 'myblog.com');
ga('send', 'pageview', {
'dimension1': 'Author Name'
});
</script>
I've placed my value for UA-XXXXXXX-XX, myblog.com and Author Name.
It has been almost a month since I've been scratching my head and hoping that the code would work. But I don't see any stats in my Analytics > Audience > Custom > Custom Variables / User Defined. I hope it is there where I am supposed to look.
So, where did I go wrong? I would be highly greatful if someone would point out what I missed.
It looks like you've named your custom dimension "Custom Dimension Name" when it should be "Author" and you'll need to add the server-side variable as the value for dimension1.
For example, if you're using WordPress, your code would look like:
ga('send', 'pageview', {
'dimension1':'<?php the_author(); ?>'
});
Also, your custom dimension scope should be set to hit.
I'm confused by the Google documentation for analytics.js
Need to track cross domains, e.g. main-site.com blog-site.com
I set up a new property in Google Analytics and received the tracking code for main-site.com.
Step 1: Installed tracking code at page bottom in main-site.com
<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-000000-X', 'main-site.com');
ga('send', 'pageview');
</script>
Step 2: instructions for analytics.js for cross domain (installed on main-site.com) Add the following before script ending tag.
// Load the plugin.
ga('require', 'linker');
// Define which domains to autoLink.
ga(‘linker:autoLink’, [‘main-site.com’, ‘blog-site.com’]);
Step 3: add tracking code to blog-site.com
// UA-000000-X is the tracking code number for main-site.com
ga(‘create’, 'UA-000000-X', {
‘allowLinker’: true
});
Problem: we need to track traffic that does not original in main-site.com. For example, a link from Facebook to blog-site.com should still count under the main-site property in GA.
For cross domain tracking you should be tracking the blog with the same tracking code number, so you will not have separate data for your blog and your main site, all the data will be in one place (if you want separate views of each site you need to set up additional profiles with profile filters to include only the traffic you want in that profile).
So if you're using the same tracking code for both, any visits to the blog (from e.g. facebook) should appear in that place. Is that not happening?
when you add the code to blog-site.com you add the entire snippet so the data is sent to the same account.
if you cant tell the difference between the 2 site s based on the url of the page with out the domain name then you need to add a filter that adds to each tracked page the host name (domain name)
see image for setting up filter