You have access to real time tracking in menu Dashboard > Visitors > Real-time.
Regarding your code, I am not expert on the PHP side. I will let someone else reply…
Hmm interestingly I can’t get my visit to appear in the real time log. I can see other visitors within minutes so this report doesn’t seem to be delayed.
Any ideas why my visits might not be appearing? I tried in Chrome normally, in a private browser and tried clearing all cookies incase I had the cookie to ignore my visits.
In Administration (cog) > Measurables > Manage > (selection of your site) > Excluded IPs, there is a list of excluded IPs
Does your request work on Chrome? From the same computer than the PHP server executing your PHP code?
url(recommended) — The full URL for the current action.
_id(recommended) — The unique visitor ID, must be a 16 characters hexadecimal string. Every unique visitor must be assigned a different ID and this ID must not change after it is assigned. If this value is not set Matomo (formerly Piwik) will still track visits, but the unique visitors metric might be less accurate.
rand(recommended) — Meant to hold a random value that is generated before each request. Using it helps avoid the tracking request being cached by the browser or a proxy.
apiv(recommended) — The parameter &apiv=1 defines the api version to use (currently always set to 1)