It's is not at all obvious how to send custom dimensions on pageviews with gtag.js. The migration guide does not offer an example: https://developers.google.com/analytics/devguides/collection/gtagjs/migration
Does anyone know how to do this?
The following should work:
gtag('set', {'dimension1': '123'});
gtag('config', 'UA-12345678-1');
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 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.
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 would like to disable Campaign Tracking on my GA property. I use Universal Analytics.
I've seen documentation here about method "_setCampaignTrack"
https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking#_gat.GA_Tracker_._setCampaignTrack
But I'm wondering how I implement it in GA Universal.
I've tried this code:
ga('create', 'UA-37650441-9', 'auto');
ga('set','_setCampaignTrack', false);
ga('send', 'pageview');
So I added
ga('set','_setCampaignTrack', false);
But I'm not sure...please help me! ;)
Any suggestions would be really appreciated.
Thanks.
_setCampaigntrack was part of the older asynchronous code and I don't think that will work. AFAIIK there is no (documented) option to disable campaign tracking in Universal Analytics (looking at the field reference confirms this).
However you could override the campaign name/medium/source-fields with the respective set field calls:
ga('set', 'campaignName', '(not set)');
ga('set', 'campaignSource', '(not set)');
ga('set', 'campaignMedium', '(not set)');
or do the same thing via filters in your view settings. That should give a similar result.