Solved

Problem with analytics code ?

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

Accepted Solution

by:
Rob Jurd, EE MVE 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

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'…
Why would you want to link Google Analytics to Google AdWords? After linking them, you can: Import goals and transactions from Analytics View  site engagement data from Analytics in AdWordsCreate remarketing lists in Analytics to use in AdWords for…
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.

810 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