Solved

Problem with analytics code ?

Posted on 2014-03-31
3
192 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
3 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
Comment Utility
yes, this is the problem!
you must have the same code
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 250 total points
Comment Utility
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
Comment Utility
Thanks
I changed all the code in the .htm pages.
I will wait to see if that fixes the issue
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Read about the 3 stages of the buyer's journey: awareness, consideration, and decision.
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now