Jump to content

Google Analytics Code and Pageviews problem


Go to solution Solved by CoffeeCake,

Recommended Posts

Hi All,

GA (Google Analytics) currently reports about 1.5 to 2 million pageviews per month for my site, while AWstats actually reports 11.8 million, this with ICS 4.5.4.2. The discrepancy is huge, IOW, a multiple of what it was with 3.4.x, when the factor difference was about 2.

On the Analytics page in the ACP, you can actually enter GA code, Matomo, etc. However, it appears to be muttually exclusive because it empties the 2nd and 3rd block when you use any of the other options. Which means the only choice is to use the "Other" field and copy all of your code there. This is needed too, I guess, for advertising scripts and such, which require parts to be in the header.

In the past I used to put all of these codes in each theme separately, in the globalTemplate for each theme. Storing these codes in a single, general ACP space is much more convenient, because it does not require you to alter themes over and over again after an update or upgrade.So, I really like the new option to do this :).

It appears however, that the different spaces for the different analytics services are mutually exclusive. I also realize there is the option now to add the GA code in a separate space, which is supposed to put it in every generated page - that should get around the reported pageviews problem. However, whenever I try that, the site just hangs. This may be caused because of the other js code I also put in these spaces, or I am maybe overlookign something, but it really only happens upon copying the GA code to that area.

Below is the "Other" option in Analytics, with advertising script added.

Analytics-Other-01.thumb.png.ab94fa293fc2ab4b40bb2079a8241fe1.png

Now, if you add that code to the pagination block as well, you get the following:

Analytics-Other-02.thumb.png.eea4accf64e91fc7631d79803c0ee472.png

So, 4 blocks all of a sudden. Now the question rises, where would I have to put what, and do I have to repeat any of the code?

Do I put GA code in the top block, and in the 4th from the top, or just at the top?

Where do I put any Matomo code? Only in the 2nd block, or in 2nd and 4th?

And advertising js, for which I have 2 scripts, where would I put that? Only in the 3rd block, or in 3rd and 4th?

Or all different again?

Any help with this would greatly be appreciated.

Thank you in advance.

Kind regards, Wim

P.S.: Putting the advertising scripts in block 4 makes the site hang too, even if it is the only place where it is present.

 

 

Edited by wimg
Link to comment
Share on other sites

7 minutes ago, CoffeeCake said:

Do you have Use AJAX pagination enabled in your theme settings (this is a setting per theme, so check all of them if you have multiples)?

Thank you for your quick reply, much appreciated!

Yes, I have. Should I switch that off?

I also have fluid wdth switched on.which is the next option.

In addition, the one thereafter, "Javascript include location" is set to "Just before </body> tag". Should I switch this to "Inside the <head>"?

Thank you in advance!

Kind regards, Wim

 

Link to comment
Share on other sites

I think the issue you're running into is that you're pasting advertising code into boxes that are intended to be only for analytics integration.

If you simply provide your GA code and choose Google Analytics, I think you'll find that everything works as expected.

If you choose other, you'll need to put the necessary bit of code GA needs to register those AJAX pagination calls. This is likely why you have such vastly out of sync numbers from AWStats vs. GA. GA isn't getting called properly when you choose other, because you're not providing the script in the "Custom code to execute on pagination" box, and instead are posting some random ad call.

You should create an advertisement natively to insert your ad code or edit your theme as is appropriate for ads. See: 

 

Link to comment
Share on other sites

Thank you, CoffeeCake.

I'll switch of Ajax pagination to start with, and check what that will do to GA for pageviews.

As to the advertising code: I need to call a piece of standard js, which has to be in the header, and per advert a div with a unique identifier which that js actually knows. This is not Google Adsense, BTW, something different.

Neither am I using the default advertising stuff as far as it is part of the ICS. I am actually using a very versatile custom made add-on, which allows me to do a lot more, and have easy control over displaying a variety of adverts, in a variety of positions, forums, apps, member groups, themes, allowing all ads to be switched off or specific ones, etc., etc. This for each advert individually, or for groups of advert, or both.

Anyway, what you are basically saying, if I understand it correctly, is to switch of Ajax pagination for GA, and put my advertising javascript code in the headers of each and every theme - exactly that which I wanted to avoid :). I really thought the analytics stuff was goign to help, basically as what it should do, and as far I understand does as well, is place the specific piece of code in the header of each page, where I would want it.

Please do correct me if I am wrong.

Kind regards, WIm

 

Edited by wimg
Link to comment
Share on other sites

47 minutes ago, wimg said:

Anyway, what you are basically saying, if I understand it correctly, is to switch of Ajax pagination for GA, and put my advertising javascript code in the headers of each and every theme - exactly that which I wanted to avoid :). I really thought the analytics stuff was goign to help, basically as what it should do, and as far I understand does as well, is place the specific piece of code in the header of each page, where I would want it.

No, I'm suggesting you select "Google Analytics" in the analytics settings and just paste in your GA identifier in the box. Not a script call.

Then, use some other mechanism to deal with ads. This section is not intended for ads, and the way you're trying to shoehorn it in is likely the reason for your odd results.

Link to comment
Share on other sites

36 minutes ago, CoffeeCake said:

No, I'm suggesting you select "Google Analytics" in the analytics settings and just paste in your GA identifier in the box. Not a script call.

Then, use some other mechanism to deal with ads. This section is not intended for ads, and the way you're trying to shoehorn it in is likely the reason for your odd results.

Ok, thank you. I still want GA to deal with every page, so I guess I should use the GA option for ddynamically generated pages, and then put everything else in the globalTemplate header (Alexa and advert scripts). Correct?

My only hassle is that one of the two advert scripts deals with pages on a similar basis as the GA pages - otherwise I will get paid for 1.2 to 2 million views rather than 11.8 million 🙂. Should I try putting it in the GA box, inderneath the GA script, and see what it does?

Kind regards, Wim

Link to comment
Share on other sites

  • Solution
21 minutes ago, wimg said:

Ok, thank you. I still want GA to deal with every page, so I guess I should use the GA option for ddynamically generated pages, and then put everything else in the globalTemplate header (Alexa and advert scripts). Correct?

Select "Google Analytics" in the section in which you provided a screen shot, and insert the tracking code (beginning with UA-XXXXXXXX). Don't touch anything else on that page. If you do that, Google Analytics will work exactly as you expect regardless of your theme settings.

If you are using Google Analytics 4 (formerly App+ Web), this will not work. IPS does not support that natively in 4.5 as of today.

If you want to include scripts for other services in addition to Google Analytics, or that are not Google Analytics or Matomo, you will need to create a custom plugin that does so or edit your templates as those providers instruct you to do.

If you do anything other than the above (i.e. choose the Other box), and don't know what you're doing, you're going to end up with unexpected results, as you are currently seeing.

Link to comment
Share on other sites

Thank you, CoffeeCake, your assistance with this problem is very much appreciated!

I'll make sure to follow your instructions!

I'll also report back my results here, both on GA, script and pageviews, as on the other scripts.

Warm regards, WIm

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...