Solved

Problem with analytics code ?

Posted on 2014-03-31
3
197 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
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)
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

751 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