2

I'm new to Google Analytics and am trying to add it to my existing PHP website. At this stage I only have access to the Content Management System which is used for creating new pages and inserting content. As far as I am aware the page already has a Classic Analytics code (ga.js) which was put there by the company who created the website.

According to the following page from Google I should be able to add a Universal Analytics tracking code (analytics.js) to my content and it should work harmoniously. https://support.google.com/analytics/answer/1032400?hl=en

I've gone ahead and added the tracking code at the end of my content for each of the pages on the site.

Unfortunately I don't think the pages views are being shown accurately when I log in and look at the stats. They are being displayed as follows:

enter image description here

Where are all the other pages? Why aren't they coming up on the list? Am I making a beginners mistake?

To make this easier for you to see what I'm talking about, the site I'm working on is This Site.

UPDATE:

I've added the Google Analytics Debug add on for Chrome. It seems to be showing the same error on each page I go to in the browser. Here's an example:

http://www.maryborougheducationcentre.vic.edu.au/community.php?id=66

Error: community.php? id=66:484 Uncaught SyntaxError: Unexpected Identifier

UPDATE:

Unfortunately I had forgotten that the Content Management System on the website uses square brackets to know where to insert html code for images. What a pain. This is what caused the two different looking tracking codes as you can see in the answer below. Anyway, at least I know what was causing problem. Thanks again Sina!

4
  • followed the tips here: support.google.com/analytics/answer/1008083?hl=en Commented Aug 20, 2015 at 0:48
  • FWIW, you should not have both ga.js and analytics.js on the same page. If you do, you'll get double counts for everything. Commented Aug 20, 2015 at 1:12
  • @PhilipWalton The page I referenced above says that it should be ok? The two tracking codes are for different google accounts? Commented Aug 20, 2015 at 1:15
  • @PaulMatthews sorry, I was just going to edit my comment to add that it's OK only if you're sending the hits to two different properties. If you send them to the same property you'll get double hits. Commented Aug 20, 2015 at 1:16

1 Answer 1

3

Why are you having 2 different codes in different pages?

For example, in index.php (working) you have:

<script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-66181918-1', 'auto'); ga('send', 'pageview'); </script> 

Whereas in your /studentservices.php?id=47 (not working) you have:

<script> (function(i,s,o,g,r,a,m){i<img style='padding:8px;' src=./images/services/'GoogleAnalyticsObject' align=right>=r;i<img style='padding:8px;' src=./images/services/r align=right>=i<img style='padding:8px;' src=./images/services/r align=right>||function(){ (i<img style='padding:8px;' src=./images/services/r align=right>.q=i<img style='padding:8px;' src=./images/services/r align=right>.q||<img style='padding:8px;' src=./images/services/ align=right>).push(arguments)},i<img style='padding:8px;' src=./images/services/r align=right>.l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)<img style='padding:8px;' src=./images/services/0 align=right>;a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-66181918-1', 'auto'); ga('send', 'pageview'); </script> 

You see the difference?

Sign up to request clarification or add additional context in comments.

12 Comments

Yes I see the difference. As I explained in my question the first one was put there by the company that created the website. The second one was put there by me. They are for 2 different google accounts. Why is the second one "not working"?
I understand, but they are both sending data to UA-66181918-1, which is the same account. How is that happening?
@PaulMatthews mate, the code above (first one!) looks right according to the example snippet we have in google tracking guides page. Is there a way for you to modify the 2nd one? Or is that controlled by the company that created the website?
I'm sorry I don't understand. When I load any page there is a tracking code in the <head> which references UA-2419955-1. Then further down in the <body> there is another tracking code which references UA-66181918-1. What am I missing?
Which one is yours mate? Can you go to your GA dashboard and check which tracking ID is yours?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.