Load Tracking payload directly via PHP?

Hi,

Currently looking into how one would load tracking data via PHP, and would be grateful for some pointers on how to do this with PHP.

QueuedTracking plugin (GitHub - matomo-org/plugin-QueuedTracking: Scale your large traffic Matomo service by queuing tracking requests (in Redis or MySQL) for better performance.) does what I want but is using Mysql/Redis as a backend, I want to use regular files that is already generated by our internal tools and source for input for Matomo to process.

Example of JSON data, this is the same data that would be in Redis when tracking users via the QueuedTracking-plugin:

{
“tokenAuth”: false,
“time”: 1560838899,
“requests”: [
{
“_idts”: “1550496955”,
“_refts”: “1559545193”,
“idsite”: “8”,
“_id”: “24d69bbaddd5dd18”,
“rec”: “1”,
“fla”: “0”,
“_idn”: “0”,
“s”: “56”,
“wma”: “0”,
“r”: “772356”,
“gears”: “0”,
“gt_ms”: “13”,
“res”: “2560x1440”,
“cookie”: “1”,
“m”: “59”,
“ag”: “0”,
“_viewts”: “1559545193”,
“pv_id”: “Q4EzEA”,
“action_name”: “X”,
“java”: “0”,
“pdf”: “1”,
“realp”: “0”,
“url”: “X”,
“_idvc”: “60”,
“dir”: “0”,
“send_image”: “1”,
“h”: “8”,
“_ref”: “X”,
“qt”: “0”
}
],
“env”: {
“cookies”: {},
“server”: {
“MM_REGION”: “12”,
“MM_LOCATION_TIMEZONE”: “Europe/Oslo”,
“MM_CONTINENT_GEONAMEID”: “6255148”,
“MM_LATITUDE”: “X”,
“MM_REGISTERED_COUNTRY_ISO”: “NO”,
“HTTP_USER_AGENT”: “curl/7.64.0”,
“MMDB_ADDR”: “X”,
“MM_CITY_GEONAMEID”: “3161732”,
“MM_ADDR”: “X”,
“REQUEST_URI”: “/X”,
“REQUEST_TIME”: 1560838899,
“MM_CONTINENT_NAME”: “Europe”,
“HTTP_X_FORWARDED_FOR”: “X”,
“MM_POSTAL_CODE”: “5803”,
“QUERY_STRING”: “X”,
“HTTP_HOST”: “localhost”,
“REMOTE_ADDR”: “X”,
“MM_LONGITUDE”: “5.30590”,
“MM_REGISTERED_COUNTRY_NAME”: “Norway”,
“MM_REGISTERED_COUNTRY_GEONAMEID”: “3144096”,
“MM_ORG”: “BKK Digitek AS”,
“MM_REGION_GEONAMEID”: “3151864”,
“MM_CITY_NAME”: “Bergen”,
“MM_COUNTRY_GEONAMEID”: “3144096”,
“MM_LOCATION_ACCURACY_RADIUS”: “100”,
“SCRIPT_FILENAME”: “/var/www/matomo-tracker”,
“MM_COUNTRY_CODE”: “NO”,
“MM_CONTINENT_CODE”: “EU”,
“MM_REGION_NAME”: “Hordaland”,
“MM_ISP”: “BKK Digitek AS”,
“HTTP_ACCEPT”: “/”,
“REQUEST_TIME_FLOAT”: “1560838899.023”,
“MM_COUNTRY_NAME”: “Norway”
}
}
}

How would I got about using Matomo, via PHP, to load this file and insert a Request ? AFAIK, I cannot post this data directly to matomo.php. As an example, QueuedTracking will load the above JSON string from the Redis queue and process it, but I’m not sure what code snippet (plugin-QueuedTracking/Process.php at master · matomo-org/plugin-QueuedTracking · GitHub) in QueuedTracking that is actually processing the request, and where error handling is done.

I’ve tried to look at the log-import tool as well for help (GitHub - matomo-org/matomo-log-analytics: Import any kind of server logs in Matomo for powerful log analytics. Universal log file parsing and reporting.), but that calls matomo.php via the webserver which in our case would create a lot of overhead.

Thanks