Solved

Problem with analytics code ?

Posted on 2014-03-31
3
195 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
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
innerHTML 7 34
Create an automated page index 9 47
Javascript Urgent help (Need help to disable event handler) 8 41
How to control cache of some js files ? 7 38
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

809 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