Server side integration with Custom Events

I am new to Pirsch and integrating analytics with the server-side implementation.

I have trouble setting up the server-side integration in my Laravel ( PHP ) project. I plan to use Pirsch to track both web ( the standard server-side integration ) and CLI application events (I am unsure if it is possible).

I’ll explain what I tried to track the CLI app events ( but couldn’t make it work ) and you can help me if I am missing something.

The CLI events flow looks like the following

  • CLI application sends a post request to my ingest server ( ) with the event details ( I am planning to use this for multiple CLI applications - and this will act as a proxy )

  • ingest server requests to pirsch hit endpoint []( ( the data will look like below )

  "url": "", <<< this is a valid url which will return 200 status
  "ip": "", <<<<< this will be the cli app user's ip address 
  "user_agent": "My CLI App v0.0.1",  <<<<< this will be dynamic based on the cli app
  "accept_language": "en-us,en;q=0.5",
  "referrer": ""
  • after a few seconds ( 5 in my case ) make the event request to the event endpoint []( ( the data will look like below )
  "url": "",
  "ip": "",
  "user_agent": "My CLI App v0.0.1",
  "accept_language": "en-us,en;q=0.5",
  "referrer": "",
  "event_name": "Error Found",
  "event_meta": {
    "errorTerm": "",
    "box": "box-1",
    "cli-app": "My CLI App v0.0.1",
    "cli-app-user": "name of the user"

the weird part is that I am getting 200 as the response code for both requests but my data is not showing up properly in the dashboard (I was able to see some data so I thought I made it work and cleared the testing records by deleting the data and after that, it stopped working ).

I appreciate your help in making it work.

1 Like

Hi Daniel,

Your use case is a bit unusual, but it should work by making a few adjustments :slight_smile:

Primarily, Pirsch is a web analytics tool. This means we have to do a lot of bot traffic filtering, and we use the User-Agent as well as the referrer for that (in addition to a few other fields).

I think the most likely reason why the traffic doesn’t show up is the User-Agent. It’s too short and doesn’t look like a real browser (no name, operating system, …). Could you try setting a valid User-Agent, like this one for Firefox?

Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0

You can append a unique ID if you want to. For example:

Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0 id/12345

Would be accepted. Of course, your CLI users will show up as Firefox users in this case…

You can leave the referrer empty btw. It will be ignored if it’s the same as the hostname in the URL.

We always return status code 200, even if the request has been dropped by our bot filter. Otherwise, spammers could use the API to check which bots will get through and which don’t.

Hardcoding a valid User-Agent seems to fix the issue :stuck_out_tongue_winking_eye:.

It makes sense :grinning:.

1 Like

Awesome! I’m glad it worked :raised_hands: