GA not tracking subdomain which is Google Search Appliance - google-analytics

I have been using Urchin 6 but have just started to use Google Analytics also. I am also using Google Search Appliance for site search.
Search is on a subdomain i.e. www.search.mysite.com
The problem is that Google Analytics is tracking site search as a self-referral. After a lot of reading online I have ended up with the GA code configuration below which should be picking up the search subdomain but it isn’t. Can anyone see anything incorrect about my configuration?
- E.g. is the GATC request process order correct
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-1']);
_gaq.push(['_setLocalRemoteServerMode']);
_gaq.push(['_setLocalGifPath', '/__utm.gif']);
_gaq.push(['_setDomainName', 'mysite.com]);
_gaq.push(['_addIgnoredRef', 'mysite.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
I have a suspicion that the issue could lie with the configuration of GA on Google Search Appliance. When you add GA it just asks for the UA code on the XSLT and you send up with the script below on each search page:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">
<!--
_uacct = "UA-xxxxxxx-1";
urchinTracker();
//--></script>
Could this be the problem or does this code need to change in the XSLT or maybe not?
Any help would be appreciated.
Thanks

I don't have a complete answer for you, as I'm trying to work out some glitches myself. But maybe this will help suggest approaches.
I'm using version 6.8.0.G.30 of the search appliance.
I can insert my Google Analytics account number in the Analytics Account field under the "Global Attributes" section of the Page Layout Helper for the desired Appliance Front End.
That GUI approach has the effect of inserting the account number into the XSLT for that Front End:
<!-- *** analytics information *** -->
<xsl:variable name="analytics_account">UA-1234567-1</xsl:variable>
When the transformation is processed and the page is rendered, if a value is found for the account, then this JavaScript is generated in the search results page:
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script><script type="text/javascript">
var pageTracker = _gat._getTracker("UA-1234567-1");
pageTracker._trackPageview();
</script>
As an alternative to using the Page Layout Helper, you can "Edit underlying XSLT code" to manually edit the stylesheet and insert the analytics account.
The Google Analytics code produced by the default XSLT may not be what you want (probably isn't based on your post). For example, the snippet above is the synchronous version.
So, you'll probably want to edit the XSLT anyway to modify the snippet. I wanted to use the asynchronous snippet, so I changed the template named "analytics" used in the XSLT (that specifies to not customize):
<!-- **********************************************************************
Analytics script (do not customize)
********************************************************************** -->
<xsl:template name="analytics">
<xsl:if test="string-length($analytics_account) != 0">
<script type="text/javascript" src="{$analytics_script_url}"></script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("<xsl:value-of select='$analytics_account'/>");
pageTracker._trackPageview();
</script>
</xsl:if>
</xsl:template>
That template is where the account information you've previously entered in the XSLT (via GUI or XSLT) gets substituted in. It's called at various locations in the Front End XSLT.
It's also possible to change the URL for the analytics script (you see that variable used in the "analytics" template).
What I did was to substitute the "analytics" template above with my own asynchronous version. So now when I look at the rendered search results, I see the async snippet there.
In my _setDomainName method, I have a leading period before the domain: .mysite.com which is consistent with the other Google Analytics-enabled pages on the rest of our site.
The "best practice" for this seems to be an area of some discussion: http://www.roirevolution.com/blog/2011/01/google_analytics_subdomain_tracking.php
Many of the comments on that post refer to self-referrals.
On the appliance search results page, the Google Analytics snippet appears immediately following the <body> tag.
The discussion of where to locate the asynchronous snippet (or "parts" if it's being split) has been raised in repeated forum posts:
http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=71ba44443f0bfbc3&hl=en
http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=22ac794d8f26a2f4&hl=en
This has been a pretty good reference for me on the asynchronous snippet:
Asynchronous Tracking Usage Guide:
http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html
Moving the snippet to <head> would take me some thinking and a more thorough look at the XSLT (and probably tweaking that would be jeopardized with future appliance versions and potential XSLT changes)
In terms of debugging Analytics, I've started to focus on investigating the values of GA-specific cookies and the __utm.gif using Firebug and other similar browser tools.
This post:
http://blog.vkistudios.com/index.cfm/2008/12/17/Slicing-and-Dicing-Cookies--Part-2--Body-Parts
as well as its followup, and other pages at that site have really helped suggest an approach to troubleshooting.

Related

Google Analytics does not show Pageviews

I have started to develop my first Typo3-Website.
To track interactions I have included Google Analytics with the following-code in the Setup-Section of the main-template:
page.headerData.9000 = TEXT
page.headerData.9000.value(
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-04738GHDL1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-04738GHDL1', { 'anonymize_ip': true });
</script>
)
With Google Tag Manager-plugin I am able to verify, that a global-site-tag is sent to my G-04738GHDL1 tag
But I am not able to see anything in Google Analytics. Account and property is selected correctly.
Any ideas?
You don't need to anonymize the IP, it is a parameter not foreseen in GA4 since anonymization is always active.
So try replacing this:
gtag('config', 'G-04738GHDL1', { 'anonymize_ip': true });
with this:
gtag('config', 'G-04738GHDL1');
If the TypoScript Object page.headerData.9000 is not overwritten somewhere else in your TypoScript it should work fine. You can check the TypoScript Object Browser in the Template module for that.
Set up correctly, the code should be output in your site's HTML.
From there I would suggest having a look at your browser's inspector tools, checking the console tab for any errors (e.g. regarding JavaScript errors or any CSP violations) and the network tab whether any request towards google are sent.
If you aren't familiar with that, the Google Chrome browser extension Tag Assistant is quite helpful. ;)

What data are we capturing in Google Analytics from an embedded iFrame we own that resides on a third-party site?

I was asked to create a Google id for our marketing department to be able to use to track their ads. I had no idea these ads were being delivered as an iFrame (without head tags, just html) into a third-party site (that can be on the web or on desktop software). Now the department wants to know what they've been tracking, and I can't seem to figure it out. I see a TON of pages, but I can't actually find the url of the iFrame. Are these pages the containers for that iFrame? Am I going to be able to pull anything useful/accurate from this data?
FYI - the google analytics code is on the iFrame and it looks mostly like this (I pulled out a ton of CSS and HTML that isn't necessary to see):
<!-- Google Analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxxx-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
<style type="text/css">#charset "UTF-8";/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */<style type="text/css">#charset "UTF-8";/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
body{margin:0; padding:0}
</style>
<div id="modal_inject">
<!--Modal content goes here-->
</div>
cross-domain Iframe tracking can be really tricky to set up.
First, It is necessary to have access to both domains (parent domain and iframe domain), which you have.
Then , what do you want to track ?... with GTM you can pull up a lot of data... but you need to know exactly what is very interesting for you business (pages view, form sent, videos viewed...).
Some insights...
Wanting to know what is going on on the iframe > GA code on iframe domain sending data to a Google Analytics Property (same or different property of the parent domain).
Wanting to track users on the parent domain AND the iframe ? > Need cross-domain tracking (GA code inside both domains, sending data to the same GA property,and allowing GA Linker for cross-domain tracking).
Wanting to make parent domain and Iframe communicates ? (sending each other some data) > the hardest task because you will face the "same-origin policy" with an Iframe domain being different from the parent doamin.
here are some useful resources that might help you :
Tracking Cross-domain Iframes from Simo Ahava
Cross-domain iframe tracking with GTM
Google analytics and Iframes by Bounteous
Hope This can help.

Impact of new "gtag.js" AdWords conversion tracking code on existing UA setup

I got an email from Google requesting a change to my AdWords conversion tracking setup. They want me to add new library "gtag.js" and some calls to a "gtag" function.
This seems pretty easy. In my research, though, I've read some things that give me pause, e.g.
"If you have Universal Analytics code on-page and are using any sort of customization to send events, virtual pageviews or other unique data to Analytics, you will likely not want to switch to gtag.js. That would mean updating all on-page customized code to the new gtag syntax. Not sure if you have custom code? Any use of custom dimensions, custom metrics, or events is likely relying on your current implantation of Universal Analytics."
(Source: https://www.bounteous.com/insights/2018/01/30/guide-adwords-conversion-tracking-2018/)
I definitely have Universal Analytics calls in place; I'm not 100% sure what they mean by "on-page" (where else would they be?) but I suspect my stuff qualifies. As for "customization," I do make use of the numbered dimensions (e.g. ga('set', 'dimension4', creditStatusCode) )
Does this really mean I should avoid gtag.js, though? I'm thinking not, but I'd also like to understand what that Bounteous.com post means.
One hunch I came up with is that the post is talking about sites that have actually made their own version of the UA script (i.e. modified analytics.js- I have not done this). Is that it?
You could use Global Site Tag for Google Ads conversion tracking without changing your current GA tracking setup at this point in time (though you would want to look at updating, once you have had a chance to check what needs to be ported over from Universal syntax to Global Site Tag).
If you were to only use gtag.js for google ads it would be similar to the following:
<!-- Global Site Tag (gtag.js) - Google AdWords: GOOGLE_CONVERSION_ID -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-GOOGLE_CONVERSION_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-GOOGLE_CONVERSION_ID');
</script>
If you were to combine the GA and Google Ads tracking the snippet would be along the following line
<script async src="https://www.googletagmanager.com/gtag/js?id=GA-PROPERTY_ID">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA-PROPERTY_ID');
gtag('config', 'AW-GOOGLE_CONVERSION_ID');
</script>
Custom dimensions would need to be mapped in the GA config command
https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
You would also need to update any event tracking to the gtag.js syntax, and same would apply to things like ecommerce tracking and so forth.
There is an analytics.js to gtag.js migration guide available
https://developers.google.com/analytics/devguides/collection/gtagjs/migration

Is google experiments API available in analytics.js?

We try to set up google experiments to work with our backend setup and found that there is API for letting GA know what variation we have selected to show for the user through function:
cxApi.setChosenVariation(chosenVariation, opt_experimentId);
When I visit official docs: https://developers.google.com/analytics/devguides/collection/gajs/experiments
it says that:
"ga.js is a legacy library. If you are starting a new implementation we recommend you use the latest version of this library, analytics.js. For exisiting implementations, learn how to migrate from ga.js to analytics.js."
We do use analytics.js.
Does it mean that all the functions present in ga.js are already in analytics.js and we do not need to worry about using this function?
You can try the browser-only Implementation as explained at https://developers.google.com/analytics/devguides/collection/analyticsjs/experiments. Instead of ga.js or analytics.js, you can try gtag.js. Visit https://developers.google.com/analytics/devguides/collection/gtagjs/migration to learn how to migrate from analytics.js to gtag.js. I am sharing the code below of how I implemented my experiment. Remember to create the experiment in Google Analytics, you will find it in the BEHAVIOR > Experiments section. In the code below, you will need to use your own Experiment ID.
<head>
.......................................
.......................................
.......................................
<!-- Load the Content Experiment JavaScript API client for the experiment -->
<script src="//www.google-analytics.com/cx/api.js?experiment=MY_EXPERIMENT_ID"></script>
<script>
// Ask Google Analytics which variation to show the user.
var chosenVariation = cxApi.chooseVariation();
// Define JavaScript for each page variation of this experiment.
// Wait for the DOM to load, then execute the view for the chosen variation.
$(document).ready(function(){
switch (chosenVariation) {
case 0:
// Original: Do nothing. This will render the default HTML.
break;
case 1:
//document.getElementsByClassName('logo_tagline')[0].value = 'I love programming';
$(".logo_tagline:first").text("I love programming");
break;
case 2:
//document.getElementsByClassName('logo_tagline')[0].value = 'Programming is my passion';
$(".logo_tagline:first").text("Programming is my passion");
break;
case 3:
//document.getElementsByClassName('logo_tagline')[0].value = 'I enjoy writing code';
$(".logo_tagline:first").text("I enjoy writing code");
}
});
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXXX-X');
</script>
</head>

Google analytics: two websites and one set of stats?

I have two websites:
http://unit.example.edu
and
http://m.unit.example.edu
The second website is a smartphone version (simplified, just a few pages of basic information) of the first website. The first website already has google analytics code there.
The top of the pages of the first website has code for detecting a visitor's device. If it is smartphone, directs the access to the mobile website. The first website's google analytics code is in the bottom of its pages.
Now I need to put google analytics into the second website.
I hope to be able to see the combined stats of both websites without manual addition. If possible, I also I want to see the stat of just for the second mobile website.
Should I just reuse the google analytics code (see below) in the second website? What is the right way?
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." :
"http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost +
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-YYYYYYY-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
Regards.
As requested, an answer.
I'd keep only the UA (Universal Analytics) tracking script on both sites. Make sure you test it first before relying on it to gather data correctly (easily monitored via analytics' real time metrics). Then set the proper views and filters. You can make multiple views to make sure you have everything set up correctly. One view should always be unfiltered (in case something is wrong with one of your filters; GA doesn't save filtered out data).

Resources