-1

i have created a page tracking script and placed it in the client side and i have also added the GA code to it. The difference between both the code is not constant sometime.

GA      Personal script  
450       212  
2500      850  
360       110  

the ratio is like this but the url visited are common and unique count is same.
The client wants to know how the difference is coming.
can anybody explain me how GA is working on getting the page views / clicks per page?

  • Have you tried searching the internet? There are several articles related with this issue. We can't say anything unless we see the whole picture. – Rüzgar May 18 '17 at 16:34
  • @piyush See my updated answer below. – Andreas May 20 '17 at 16:05
  • How does your tracking script work? – ceejayoz May 20 '17 at 16:05
  • @ceejayoz i am using the script to call my url to save what is opened and when it is clicked by making the ajax call – piyush saraf May 22 '17 at 16:25
  • @Rüzgar i have searched the internet but it is not showing me the path on which the code is working – piyush saraf May 22 '17 at 16:26
  • Can the downvoter please comment on why you have downvoted my question? – piyush saraf May 23 '17 at 06:31
  • @piyushsaraf I did not downvote, but probably because you say you have made a trackingscript and then does not include it in the code. The problem may be in your code and you don't know it. But have you even looked at my answer? I'm seriously considering giving you a downvote just because you have not even replied to my answer. I have given you all what you ask for in the answer. – Andreas May 24 '17 at 04:58

1 Answers1

-1

It's most likely because of spam views on the GA account.
You can see it on referrals.
Do not go to the sites you see there as it's only spam and meant to get you there.
It could be viruses.

See here how to get ride of it.
This is the best way, a normal filtering method is not good enough.

Removing spam referrals in Google Analytics doesn't work anymore for some referrers

I see that you have edited your question with: "can anybody explain me how GA is working on getting the page views / clicks per page?"

Google Analytics use javascript to get the views and clicks.

This code:

<!-- Google Analytics -->
<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','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto'); // <-- this is the ID
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

Is the part sends the data form your page visitor to GA.
And since javascript is written in plain text, anyone can take your UA-ID.
And that is what the spammers do, they take your UA-ID and create traffic on your UA-ID (not your actual page).
They do this because they want to trick you as an admin to visit their page since it shows up as referal page.

Had the GA-code been PHP the UA-ID would not have been so easy for the spammers to get hold of. But it would also mean a less powerfull GA since you need the users data in a lot of the things.
You can't get the same kind of data about the user in PHP as in javascript.

As I mention in the answer I link to above, you can easily get ridd of all this fake data from GA by adding a dimension. This is a variable that the user sends to GA that you decide.
If the user does not send this variable you know they are not on your page and you can filter out that data.

I hope this helped you to answer the question.

Community
  • 1
  • 1
Andreas
  • 23,610
  • 6
  • 30
  • 62
  • i just wanted to understand the script that is running as the count in both the script is near about having double the count so was eager to understand the code, as the count of google analytics is 200 then my personal script gives me 100 and so does the statcount script give me the same – piyush saraf May 24 '17 at 08:54
  • @piyushsaraf And that is what I have explained above. You have referal spam in your GA count. Remove the spam with the simple fix I linked to and you will have near identical numbers on your script and GA. – Andreas May 24 '17 at 09:06
  • can you provide me the link that is there for the spam conversion as i am not able to locate that referal spam – piyush saraf May 24 '17 at 09:10
  • Here you can read about it. https://www.optimizesmart.com/geek-guide-removing-referrer-spam-google-analytics/ But do not follow their way of blocking the spam it will not work. The spammers will only change the referal page from "dodar" to "doodar" and your filter won't work. However my method works since it requires the user to be on your page for GA to count it. – Andreas May 24 '17 at 09:31