I have setup custom dimensions as follows
My source code shows as this:
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXXXX-1', 'auto');
ga('send', 'pageview');
ga('set', 'dimension1', 'Manager');
ga('set', 'dimension2', 'Recruitment');
ga('set', 'dimension3', 'Leave');
</script>
It's been in place for 24 hours. However when I go to my Google Analytics account > Home > Behaviour > Site Content > All Pages, and then add any of the custom dimensions I've created, no data is brought back.
Am I doing something terribly wrong or does everything look ok?
Swap it so that it is this way:
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXXXX-1', 'auto');
ga('set', 'dimension1', 'Manager');
ga('set', 'dimension2', 'Recruitment');
ga('set', 'dimension3', 'Leave');
ga('send', 'pageview');
</script>
This is because the "hit" doesn't get sent with ga set. The ga send is the only hit there.
Related
we have two tracking codes on our site. On both codes we get tracking of visitors and stuff correct, but when it comes to events, only one is getting the event even tho' we're sending it to both codes.
This is the setup:
ga('create', 'UA-12345678-6', 'auto');
ga('create', 'UA-123456-4', 'auto', 'clientTracker');
ga('require', 'displayfeatures');
ga('clientTracker.require','displayfeatures');
ga('require', 'ecommerce', 'ecommerce.js');
ga('clientTracker.require','ecommerce','ecommerce.js');
ga('send', 'pageview');
ga('clientTracker.send', 'pageview');
and this is the event:
$("#desktopCheckout").on("click", function() {
ga('send', 'event', 'test', 'clickOnCheckout');
ga('clientTracker.send', 'event', 'test', 'clickOnCheckout');
});
The event is being sent to the regular tracking code, but not to the "clientTracker".
Are we doing something wrong here?
GA Debug extension and Tag assistant extension in Chrome both shows that the event is being sent, and I've checked the tracking ID so it is correct. Just somehow Google Analytics is not recieving this.
i manage several hotels on analytics, actually have like 400, and we are updating the ecommerce data to enhanced ecommerce.
when i updated the scripts to e ecommerce on 100 hotels, no one was working, so i ran a test and i found that the isogram analytics code wasnt implemented, fixed that and now 70/100 hotels are getting ecommerce data.
idk if is matter of time to get the data on the last 30 hotels but here is the code, if anyone can see anything wrong, thanks.
<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', 'viewcode', 'auto', {'allowLinker': true});
// Load the plugin.
ga('require', 'linker');
// Define which domains to autoLink.
ga('linker:autoLink',['websites']);
ga('send', 'pageview');
ga('require', 'ec');
ga('set', '&cu', 'MXN');
ga('ec:addProduct', {
'id': '{SkuCode}',
'name': '{ProductName}',
'category': '{Category}',
'price': '{UnitPrice}',
'quantity': {Quantity}
});
ga('ec:setAction', 'purchase', {
id: '{NoReservation}',
revenue: '{Total}',
tax: '{Tax}'
});
ga('send', 'event');
</script>
The analytics code that you are using it looks right, however in order to assure that analytics code is pushed from the all the hotels websites I recommend you to follow the following steps:
1) Check that hotels domains name are correctly in the "linker" parameter
2) Verify that those websites dont't have another GA analytics code that overwrite your code. In order to avoid conflicts I recommend you to rename the "ga" global object to "myga" or something like that. Example:
<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','myga');
myga('create', 'viewcode', 'auto', {'allowLinker': true});
// Load the plugin.
myga('require', 'linker');
// Define which domains to autoLink.
myga('linker:autoLink',['websites']);
myga('send', 'pageview');
...
You can check when a hotel is pushing events if you are using the GA Real-time in the GA dashboard.
(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', 'Tracking ID', 'Domain'); // Replace with your property ID.
ga('send', 'pageview','URL');
You're problem is this line:
ga('create', 'Tracking ID', 'Domain'); // Replace with your property ID.
It should have your GA property Id in it which will begin with UA. Something like this:
ga('create', 'UA-12345678-1', 'auto'); // Replace with your property ID.
You can find the property id under the Home section of Google Analytics. Or alternatively look at Admin->Property->Tracking Info-Tracking Code.
I'm trying to use Google Analytics (web) with my polymer app (updating the tracker object in routing.html as per this GA SPA doc). I used the Polymer Starter Kit as a starting point. I'm not seeing any pageviews though, apart from / - what's the suggested way of tracking app usage?
routing.html
page('/topstories', function () {
app.route = 'topstories';
window.ga('set', 'page', '/topstories');
});
page('/about', function () {
app.route = 'about';
window.ga('set', 'page', '/about');
});
index.html
<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-1', 'auto');
ga('send', 'pageview');
</script>
In addition to setting the page value on the tracker, you also have to send the pageview hit to Google Analytics. In your route callback functions you'll need to add the line:
ga('send', 'pageview');
You could also write a function that does all this for you, so you don't have to repeat the set and send calls every time.
function updatePage(path) {
return function() {
app.route = path.slice(1);
ga('set', 'page', path);
ga('send', 'pageview');
}
}
The your page route declarations would look like this:
page('/topstories', updatePage('/topstories'));
page('/about', updatePage('/about'));
My solution takes advantage of the middleware-ish page.js handler:
// Routes
page('*', scrollToTop, closeDrawer, function(ctx, next) {
ga('set', 'page', ctx.path); // simply add
ga('send', 'pageview'); // these rows
next();
});
But this also fires as the / route is initialised, so to not double count visits, remove the final ga('send', 'pageview'); from your <script> block.
I have issue to track campaign not with the help of url
http://domain.com/page?utm_campaign=xxx&utm_source=xxx&utm_medium=zzz
but javascript call.
According to the information given here developers.google.com and my inpage google analytics universal 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-zzz', 'domain.com');
ga('send', 'pageview');
</script>
I've tried to send inforation about campaign in many different ways, but all of them were unsuccessfull. I haven't found campaighn data in Analytics reports.
///
ga('_setCampNameKey', 'xxx'); ga('_setCampSourceKey', 'yyy'); ga('_setCampMediumKey', 'zzz');
///
ga('send', '_setCampNameKey', 'xxx'); ga('send', '_setCampSourceKey', 'yyy'); ga('send', '_setCampMediumKey', 'zzz');
///
ga('push', '_setCampNameKey', 'xxx'); ga('push', '_setCampSourceKey', 'yyy'); ga('push', '_setCampMediumKey', 'zzz');
///
ga('set', '_setCampNameKey', 'xxx'); ga('set', '_setCampSourceKey', 'yyy'); ga('set', '_setCampMediumKey', 'zzz');
///
ga('set', 'CampNameKey', 'xxx'); ga('set', 'CampSourceKey', 'yyy'); ga('set', 'CampMediumKey', 'zzz');
///
ga('set', 'campNameKey', 'xxx'); ga('set', 'campSourceKey', 'yyy'); ga('set', 'campMediumKey', 'zzz');
What is the right way to track campaign info?
I struggled to find the answer to this, too, so even though this question is super old, I wanted to leave this here for others to find.
The analytics.js replacement for _setCampNameKey (and the other campaign tracking parameters) can be found here:
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#campaignName
And this page has a full example of how to implement them:
http://randomproblems.com/how-to-setoverride-campaign-variables-in-google-analytics-universal-with-js/
gv0zd's answer is correct except that the Campaign parameters have to be set before sending the pageview. If you send them after (as in gv0zd's example), it does not work.
This is the solving of the problem
<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-zzz', 'domain.com');
ga('send', 'pageview');
///////
ga('set', 'campaignName', 'XXX');
ga('set', 'campaignSource', 'YYY');
ga('set', 'campaignMedium', 'ZZZ');
</script>