Google Analytics Tracker not working in ASP.NET website - asp.net

I've got a client with about 6 websites that are all the same framework in VB.NET. I've tried to add Google Analytics Tracker inside each of them with no success. I've many clients with WordPress website or with my custom CMS (in JavaServer Faces) that are working perfectly. I'm pretty sure I'm doing something wront in VB.NET which I almost never use.
Here is the code in VB.NET I'm currently using :
<head>
...
<!-- Google Analytics -->
<asp:ContentPlaceHolder ID="GoogleAnalyticsTracker" runat="server">
<script type="text/javascript">
alert('ga-start');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<%= m_sIDGoogle %>']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_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);
alert('ga-stop');
}
)();
</script>
</asp:ContentPlaceHolder>
</head>
Note : I've tried just before the </body> too, as described in Google Analytics.
Here is the rendered result :
<script type="text/javascript">
alert('ga-start');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA–29119317–1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_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);
alert('ga-stop');
}
)();
</script>
Also note that the two alert('') are working, Firebug tell me that the ga.js is loaded too.
After all that, nothing is tracked in Google Analytics. Someone have an idea of what I'm doing wrong?
You can also visit the test website : http://mouk-mouk.amiesterre.com

Finally fixed, I don't know why, but the codes were wrong :
UA–29119317–1 > UA-29119317-1
UA–29119317–1 > UA-29119317-1
Visually we see nothing in Courier New...

Related

Google analytics on one site with different domains

We how a site that is accessible from two different domains. let it be original.com and new.com
We have such sript
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-*******-**']);
_gaq.push(['_setDomainName', 'original.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>
The problem is that in GA I see sessions from origina.com but I don't see sessions from new.com
How should I modify code above to be able to see sessions from both domains in one Google Analytics View?
UPDATE
Both domains has points to one app by main damain and to another app by subdomain. So original.com and new.com point to one app and sub.original.com and sub.new.com point to another app.
I need to see both original.com and new.com in one view and sub.original.com and sub.new.com in another view

Google Analytics custom variables not showing up

I have been running this code for some time now on all pages. This custom variable has never shown up.
Sorry to ask this again, I don't see another post that solves my case. This has to be the simplest case in the world, this is the same code with only the UA changed:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, 'User', 'jc', 3]);
(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 did not modify the (function()...) .. Do you see the problem? I'm using slot 1 with the page level (3) scope. The same code appears on each page for a given user.
_setCustomVar does not trigger a request to GA. _trackPageview does. You have to move the _setCustomVar above the _trackPageview.

google analytics setup, not tracking

I'm trying to implement google analytics on a page but it refuses to track anything.
the public domain is on www.publicdomain.com, when entering the page its redirected to: www.publicdomain.com/sub1/sub2/index.php
this website is hosted on another domain:
www.privatedomain.com/publicdomain/sub1/sub2/index.php
This is the GA code I'm using inside the body tag of the index.php file:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9999999-9']);
_gaq.push(['_setDomainName', 'publicdomain.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>
Any ideas of what could be wrong?
Here are some things to check:
Are you using the correct UA number? (i.e. not 999999-99)
Are the GA cookies being created? (__utm[abcz])
Is the __utm.gif request being sent back to Google? If not, is your browser blocking it? (i.e. is Do Not Track enabled?)

Google Analytics Custom Variables not working

I am trying to log the username of users who are using my system. Unfortunately, I couldn't track by using custom variables. I could track the page visit, but custom variable tracking is not working. Could you please help me? Thanks.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setCustomVar',1,'UserName','JohnPaul',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);
})();
</script>
The code is correct and it does track the users now. I just used the similar codes as above and it works now. But I needed to wait 2 days to track the custom variables and it appears in my reports now.
For more than one user, you'll have to use PHP to output user names.
_gaq.push(['_setCustomVar', 1, 'UserName', '<?php get_usernames(); ?>',2]);
***Substitute "get_usernames" with the function for your site that retrieves the usernames.

How do I track 2 domains which point to the same host. 2nd domain points to a sub directory of the 1st site

This is my exact setup. I have a single web host. I have assigned a primary dns to that host. for instance www.primary.com points to the host. THe host allows 'addon domains'. An addon domain is in effect a subdirectory of the host, is accessible via www.secondary.com OR secondary.primary.com. I can ALSO access the content at www.secondary.com by typing in www.primary.com/secondary.com
I want to track each domain as a totally separate website, with no overlap in the visitors. (the sites for all intents and purpose are two completely separate site with nothing really linking the two)
I am absolutely confused as to what code to use where and how to customize it. So any and all help would be appreciated.
Thanks in advance
Either you use two different profiles with unique profile ID to track them (e.g. UA-123456789-1 for the www.primary.com and UA-123456789-2 for the www.secondary.com) and make sure each site only has one of the codes, or you can use filters based on domain/sub-domain/directory structure to do this (or to support it).
I would go with separate tracking codes, as it is by far the easier choice.
Example:
Site 1:
<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>
Site 2:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-Y']);
_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>
Be sure to create the profile for both.

Resources