Solved

Problem with analytics code ?

Posted on 2014-03-31
3
199 Views
Last Modified: 2016-02-24
I read reports on my sites performance in google Analytics. Most of my pages are asp, but some are .htm
None of the .htm show in the reports.
In looking at the Analytics code the .htm looks a little different and i think that maybe the problem.
The asp code:
 var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-38122462-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);
  })();

Open in new window


The .htm code that looks a little different at the end:
<script type="text/javascript"> 
 var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-38122462-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););
</script> 

Open in new window


the .htm code ends like this
s););

Open in new window

the asp code ends like this
s);})();

Open in new window

could this be the problem?
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 39968662
yes, this is the problem!
you must have the same code
0
 
LVL 43

Accepted Solution

by:
Rob earned 250 total points
ID: 39968838
Just to confirm why for you....  the extra brackets ( ) are there to execute the anonymous function.  In the second set of code (that doesn't work for you) the function is defined but never executed.  In the first set of code it is executed by adding these brackets.

see my article on javascript, where I talk about Anonymous Functions:  http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_13138-Javascript-is-just-an-Object.html
0
 

Author Closing Comment

by:isnoend2001
ID: 39969564
Thanks
I changed all the code in the .htm pages.
I will wait to see if that fixes the issue
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was initially published on Monitis Blog, you can read it here . When it comes to deciding which approach to website performance monitoring is best for your business, unfortunately, like so many options in life . . . it depends. In th…
One event, two days, a great line-up of speakers, and 48% female presence. Still have no idea what I’m talking about?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question