user2143356
user2143356

Reputation: 5597

Server-side analytics and server-side logging in particular (PHP)

I need to log details in PHP of analytics and usage.

I'm looking at various possibilities:

- Google Analytics server-side
- segment.io
- Just adding a record to a DB with PHP

My concern is how much additional processing this will take on my server. Of course Google Analytics' JavaScript implementation won't use anything on my server, but my server-side method of course will.

I also notice that on https://segment.io/docs/integrations/google-analytics they mention that "Server-side Google Analytics is being deprecated due to difficulty of use" - what does this mean?

So basically, I want to implement some basic analytics storing (count number of hits to a URL + some other basic info) server-side - what's the best way to do this considering all things? I only use the PHP language.

It seems that adding a record to the DB every page view might be a little too much.

Upvotes: 0

Views: 375

Answers (1)

reinpk
reinpk

Reputation: 624

Segment.io can actually give you the flexibility of all three of these. Using the php library https://segment.io/libraries/php you can start sending events from your server. The library is designed to queue and batch to maximize server efficiency.

Once the events leave your server, they'll go to Segment.io's servers. Once there, we can route the data to Google Analytics.

Additionally, you could use the "Webhooks" integration on Segment.io to set your own server as a receiving endpoint for the data in real-time, so that you could host your own analytics DB separately from the rest of your infrastructure quite easily/cleanly. https://segment.io/docs/integrations/webhooks

Upvotes: 1

Related Questions