I have read some google analytic custom dimension explanations but still can't find a tutorial that explains the steps from beginning to end. I know many have discussed this but many tutorials are incomplete and jumping from the side of the settings in Google Analytics and from the side of laying the code in the project makes me confused.
What I have done,
First I add custom dimension from admin->custom definition->custom dimension
Then, I create a custom report from customization for showing my custom dimension
Then, I put the javascript code in my project
<script>
var test = 'test';
ga('create', 'UA-11xxxxxx', 'auto')
ga('set', 'dimension1', test);
ga('send', 'pageview');
</script>
But, If open the custom report it always returning no data(I have waiting more than a day but still no data)
Is there something wrong with what I've done or are there any steps that were missed?
Any helps will be appreciated. Thanks.
Related
I want to split test different layouts on my site, and to track this I want to use a Custom Dimension which is named Split and equal to 1 or 2.
I've configured the Custom Dimension in Google Analytics and added the code like this:
// Google Analytics
gtag('config', 'UA-70465331-1'), {
'custom_map': {'dimension3': 'Split'}
});
// Sends the custom dimension to Google Analytics.
gtag('event', 'SplitTest', {'Split': "2"});
However, when using the Google Tag Assistant, the Custom Dimension isn't appearing under Events.
The live page is: https://www.travelden.co.uk/mindblowing-new-hotels-in-the-maldives
Can anyone see where the error is?
Much appreciated!
It is coming through:
You need to be careful to set the event to "non-interaction",
I would also suggest you to not send an event if you don't need it...so something like this:
gtag('config', ''UA-70465331-1', { 'dimension3': '2' });
Doing it this way the dimension is applied when the page is loaded, which is really what you're testing, the layout.
I'm using GTM in my company's online shop, and I installed some other tag via GTM's custom HTML tag, like this:
<script>
//some JS code...
var customParam=[{"key":"value"}];
var jsElm=document.createElement("script");
jsElm.type="text/javascript";
jsElm.async=true;
jsElm.src="https://some_tags.com/tag.js?s=CV";
document.body.appendChild(jsElm);
if(today < some date)
{
SEND GA EVENT here.....
}
</script>
The traditional GA event script
ga('send', 'event', 'XXX', 'pageview', 'some description', 1);
isn't working anymore here.
How do I did this ?
And I heard someone said that I should put data into DataLayer and do some bla bla bla... but I was understanding that too few to try. Is that a right way ?
I am going to answer with another question. Why are you sending events through HTML tags instead of Google Analytics Tag that are build just for that purpose?
I ll work with the assumption that you are new with this tool but the idea is that GTM replaces all old GA code on site.
Just create a new Tag and select 'Universal Analytics' and after that you can choose which kind of information you want on Google Analytics.
Its pretty self explanatory as a tool so i strongly recommend you to forget about those old GA codes and work with what you got.
In addition to this have in mind that you can use custom javascript variables to scrap DOM values in case you need to.
Here is our guru Simo Ahava: https://www.simoahava.com/
If you need anything else just ask.
I currently have landing pages taking the following shape :
http://rootdomain/index.html?ref=[base64encoded-ref]&text=[base64encoded-text]
When I watch my stats in google analytics, I have urls looking like
http://rootdomain/index.html?ref=c3RhY2tvdmVyZmxvdw==&text=bWFyd2Fubg==
but I'd like to see
http://rootdomain/?index.html?ref=stackoverflow&text=marwann for example.
Any idea how to achieve this?
Oki so you can do this, but it can be tricky, so be careful.
Without GTM:
So on the page with Universal analytics, you can actually tell what must be the value that will be recorded. you can decode your path using JS and pass it like below:
ga('send', 'pageview', { 'page': '/YOUR-CUSTOM-PATH' });
Using GTM:
Changing the "dp" value can be accomplished in GTM by setting the desired value in the page field, under "Fields to set":
Let me know if you have doubts.
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.