google analytics not showing numeric values - google-analytics

I am trying to send an event (with a numeric value) to google analytics but the numeric value is not being shown in google analytics dashboard:
<!-- Google Analytics -->
<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', 'XX-XXXXX-X', 'auto');
ga('send', 'pageview');
ga('send', {
hitType: 'event',
eventCategory: 'test',
eventAction: 'visit_on_page',
eventLabel: 'label2',
eventValue: Math.round(Math.random()*100)
});

You can find event value in Events report (not in Real time report).

Related

Google Analytics ecommerce does not fire from local file

I am trying to set ecommerce tag firing from the local file. At the moment I am using hardcoded data.
The GA file itself is working and sending page view. However, the bit with ecommerce doesn't work. No information in the console, no errors like it doesn't exist.
The code is below:
<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-17316967-1', 'auto');
ga('set', 'checkProtocolTask', null); // Disable file protocol checking.
ga('set', 'checkStorageTask', null); // Disable cookie storage checking.
ga('set', 'historyImportTask', null); // Disable history checking (requires reading from cookies).
ga('send', 'pageview');
</script>
<script>
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id' : '298',
'affiliation' : 'Tax',
'revenue' : '0.0',
'shipping' : '0.0',
'tax' : '0.0'
});
ga('ecommerce:addItem', {
'id' : '227',
'sku' : '227',
'name' : 'Alpha 0 featured listing',
'category': 'Appliances',
'price' : '23.34',
'quantity': 1
});
ga('ecommerce:send');
</script>

Facebook Instant Article with (not set) in Google Analytics

I am running a WordPress which using Automattic/facebook-instant-articles-wp.
But I realise the traffic tracked for IA showed in GA were unable to show the title.
A lot of website is recommending this for the GA 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', 'ANALYTICS ID', 'auto');
ga('require', 'displayfeatures');
ga('set', 'campaignSource', 'Facebook');
ga('set', 'campaignMedium', 'Social Instant Article');
ga('send', 'pageview', {title: 'POST TITLE'});
</script>
Then it end up showing 'POST TITLE' in GA. Anyone have any clue to show the article title?
Thank you.
GA code like this should give you correct titles:
<script>
...
ga('create', 'XX-XXXXXXXXX-X', 'auto');
ga('require', 'displayfeatures');
ga('set', 'campaignSource', 'Facebook');
ga('set', 'campaignMedium', 'Social Instant Article');
ga('set', 'title', 'IA - '+ia_document.title); // get your title
ga('send', 'pageview');
</script>
So with ia_document.title you can get article title correct in analytics.
Here is a Facebook's reference to the issue:
https://developers.facebook.com/docs/instant-articles/analytics#analytics-services
Hope this helps.
The code that you've posted ends with:
ga('send', 'pageview', {title: 'POST TITLE'});
This is why 'POST TITLE' is coming up in GA. By editing this field, you can decide how it will be reported to GA.
There are a few answers that might be applicable here but I will show what requires the least modification here:
in your header:
<html <?php language_attributes(); ?> data-title="<?php echo get_the_title();?>">
You will need to replace your own logic for get_the_title() some pages created by use of rewrites will not have an title. But for most usage it will suffice.
<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', 'ANALYTICS ID', 'auto');
ga('require', 'displayfeatures');
ga('set', 'campaignSource', 'Facebook');
ga('set', 'campaignMedium', 'Social Instant Article');
ga('send', 'pageview', {title: document.documentElement.getAttribute('data-title')});
</script>
Since you're using embed code and not sure what could be POST TITLE, you should try document.title:
ga('send', {hitType: 'pageview', title: document.title});
See page tracking for more info. Remember to change ANALYTICS ID to actual ID too.

Two Google Analitycs, one with AutLinker

I have two sites:
example-1.com
example-2.com
I need to have one analitycs (UA-XXXXXXXX-2) only for page example-1.com.
However I also need GA (UA-XXXXXXXX-1) which will be implemented on both sites. Is this code ok for that?
I want to implement it only to site example-1.com ; site example-2.com has only one analiytics so it is done via GTM (with allow linker also).
<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-XXXXXXXX-1', 'auto', {'allowLinker': true}, {name: 'First'});
ga('First.require', 'linker');
ga('linker:autoLink', ['example-1.com', 'example-2.com'] );
ga('First.require', 'displayfeatures');
ga('First.send', 'pageview');
ga('create', 'UA-XXXXXXXX-2', {name: 'Second'});
ga('Second.require', 'displayfeatures');
ga('Second.send', 'pageview');
</script>

Google Dynamic Remarketing tag not recognized

Trying to setup dynamic remarketing. Analytics and Adwords are linked and in use for some time now.
I modified the Analytics tag to require displayfeatures and set customer dimensions. I also added an extra event and pageview tag for testing purposes.
However, in adwords I get the message "We haven't detected the Google Analytics remarketing functionality on your website."
Below are the tags currently active on the site:
<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', 'XX-00000000-0', 'auto');
ga('require', 'displayfeatures');
ga('set', 'dimension1', 'FOOBAR1, FOOBAR2, FOOBAR3');
ga('set', 'dimension2', 'home');
ga('set', 'dimension3', '44.44, 55.55, 66.66');
ga('send', 'pageview');
</script>
<script type="text/javascript">
ga('send', 'event', 'product', 'view', {
'dimension1': 'FOOBAR4, FOOBAR5, FOOBAR6',
'dimension2': 'product',
'dimension3': '77.77, 88.88, 99.99'
});
</script>
<script type="text/javascript">
ga('send', 'pageview', {
'dimension1':'FOOBAR7, FOOBAR8, FOOBAR9',
'dimension2':'cart',
'dimension3':'11.11, 22.22, 33.33',
});
</script>
I had the same issue and brought on our Adwords rep to help mediate between GA. They claimed it may have something to do with the CMS, but nonetheless asked to try it out with Google Tag Manager.
Tried Google Tag Manager and the problem went away.

Integrate GA in DPS

I didn't success to integrate Google Analytics in Adobe Digital Publishing Suite.
What I done is create a dummy html file that include ga script as :
<!DOCTYPE html>
<html>
<body>
<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-XXXX-Y', { 'cookieDomain': 'none' });
ga('send', 'pageview');
</script>
</body>
</html>
If I try on my localhost, I can see the page on the live google analytics, but if a make a html object on DPS, export it, I can see my white page but not the live stats in GA.
Is that someone success to do it and how ?
Did you embed the html in the app/magazine?
If this is the case, the webview probably adds file: before the url of the GA javascript file (so it can not be found). You can manually add https: to prevent this.
Your code should be like this:
(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-XXXX-Y', { 'cookieDomain': 'none' });
ga('send', 'pageview');

Resources