I have some code (below) that I'm using to track pageviews on Google Analytics. In Google Analytics, all pages end up having the name "$A".
I can't seem to find anyone who has had the same issue and I can't see what I'm doing wrong:
<script type="text/javascript">
(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);
})();
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);
</script>
<script src="/__utm.js" type="text/javascript"></script>
It sounds like, rather than there being a problem with the tracking code, that the problem is actually with a filter configured for your account.
Specifically, $A makes it sound like you have an improperly configured Reyes based filter that, rather than outputting the regex match, is instead outputting the string "$A", which is meaningless unless you're properly using RegEx.
Can you post detailed information about the profile? In any case, you shouldn.t be filtering on a main profile, since filters cannot be undone, so any configuration errors on your main profile will result in permanently lost data.
My recommendation is to totally remove the filters in pladce, duplicate the profile and apply your desired filters against the duplicate, to mitigate potential data loss problems like this.
Related
I paste the code just before in every webpage and it doesn´t work.
Can somebody check why?
My website is http://www.agriculturacanaria.com
It has html, asp and css files. I didn´t touch the css but the code is already in all the head section of both the two others.
I don't know if that's valid GOogle Analytics cdode. It may be an old way or something, but the modern code looks something like this:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_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>
You can probably use that code block and put in your own UA code and get it to work.
Microsoft Word makes for a really bad HTML editor, so you may want to find an alternative that allows for greater flexibility over the code and less bloat of the HTML. (You're probably being penalized for a tactic called "keyword stuffing" alone.)
Hope this helps!
I tried to look for a good solution but couldn't find any.
I try to link multiple Google webmaster tools accounts to a single Analytics property.
I tried creating multiple views, but it seems you can't link it to a view.
I found a solution to add multiple domains to a Google Analytics property, but this seems outdated since Universal tracking
Note: probably some people might say I should 301 redirect the domains for duplicate content. But they are regionaly implemented using the hreflang alternate method which should be just fine.
You can link multiple Google Analytics accounts.
<script type="text/javascript">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
// Second tracker
_gaq.push(['secondTracker._setAccount','UA-YYYYYYYY-Y']);
_gaq.push(['secondTracker._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>
See: http://seo-website-designer.com/Google-Analytics-Tracking-Multiple-Accounts
I am implementing Google Analytics for a customer that has part of their site on a subdomain on another SSL encrypted site. For example, let's say that their URL is http://www.first-site.com and they have a contact form located at https:// www.second-site.com/first-site/. Also, several other sites that run Google Analytics have part of their site on different subdomains of www.second-site.com.
(Current code for both pages in both domains is listed below)
The Analytics is running and it is tracking both domains and the cookie information is being passed in the URL from one domain to the other, however when I look at the cookie, the visitor ID changes when I go from one to the other. Is this supposed to happen?
Also, the Real Time Analytics report shows a new visitor when I go from one domain to the other. Does this mean that the cross domain code isn't working? I thought that the visitorID in the cookie would be the same from domain to domain.
Any help would be greatly appreciated and any tips for testing the cross domain analytics would be appreciated, too.
Tracking code for http://www.first-site.com: (actual UA number has been replaced)
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_setDomainName', 'first-site.com']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setAllowHash', false]);
(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>
Code for https:// www.second-site.com/first-site/ :
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_setCookiePath', '/first-site/']);
_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>
Here is an example URL from a linked page: https:// www.second-site.com/first-site/apply.htm?_utma=226662157.1705427553.1330793721.1330793721.1330802012.2&_utmb=226662157.1.10.1330802012&_utmc=226662157&_utmx=-&_utmz=226662157.1330793721.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)&_utmv=-&__utmk=195995183
You need _gaq.push(['_setAllowLinker', true]) on the second site as well.
Also make sure that the _trackPageview comes after all other calls.
If you do that you should start to see the visitor the visitorId being the same.
Also note that not all __utma cookie needs to be the same. You just need to check the second number after the first dot. If that is the same than it's probably working. The __utmz cookie also should have the same referrals.
Note that you don't need _setAllowHash anymore. It's deprecated now. And you probably don't need _setCookiePath, unless you have a very good reason to that, and the only good reason is if you have other cookies on second domain that you want to isolate.
Hi recently redesigned my site (http://bit.ly/gwrYwb) which was formerly tracking pageviews properly via Google Analytics. After the redesign, I inserted the exact same code right before the </head> tag:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_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>
(The UA number is correct on the actual page.) However, GA is mysteriously reporting zero pageviews/visits, even though it claims to be receiving data. Has anyone experienced a problem like this before? The only other JS I'm using is including jQuery, as well as a widely-used jQuery plugin on one of my pages.
This is kind of lame, but have you checked your profile filters? You might still have old filters (for the former website) applied that filter all urls out.
We had this problem with another website and were debugging for weeks until we found this simple solution...
I have tracking code A on the main site www.example.com and tracking code B on www.example.com/blog which is a wordpress.com based blog (the site itself is plain PHP).
Not surprisingly, traffic from the blog is not shown on the main site and visa versa.
I would like to use tracking code A on the blog as well to create a "roll-up" profile while maintaining the profile I currently have with tracking code B.
I thought that the right way to do it is using the following code:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['t2._setAccount', 'UA-XXXXXX-2']);
_gaq.push(['t2._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);
})();
but I read here:
http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=640080c650f67bd1&hl=en
that it causes a multiplication in visitor numbers and such.
What is the correct way to do this?
Should I explicitly specify the domain and use the _setAllowLinker() method as described in the linked post above despite the fact that it's the same domain?
Any help will be much appreciated.
Thanks,
Alexander
P.S
I read Google Analytics - async tracking with two accounts but I still don't have a definite answer.
The easiest way to achieve the results you're looking for is to use a single account/profile ID site wide and use profile filters to create a 'Blog Traffic Only' profile.
Sitewide you would call:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-1']);
_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);
})();
Then, log in to Google Analytics, select your account (if you have more than one), add a new profile (for an existing domain) under the UA-XXXXXX-1 profile number, and call label it 'Blog Traffic'.
Once you create the profile, click to 'Edit' the profile you just created. Scroll to 'Filters Applied to Profile' and click 'Add Filter'. Google Analytics provides a pre-defined filter for traffic to a subdirectory (include only traffic to the subdirectories that are equal to '^/blog.*' or just '/blog').
Now, you'll have a profile that includes all traffic to your site and a second profile that includes traffic only to the blog subdirectory.
More information on using data filters:
http://www.google.com/support/analytics/bin/answer.py?answer=55496