Hybrid usage of JS and PHP for ecommerce event

Hi everyone,

I had built a custom ecommerce platform, it is using nextjs and laravel as API backend. Currently I trying to add ecommerce tracking feature into the platform, and due to the design of my frontend, the total cart amount is not getting from API call every time when there is cart item changes.

So, I trying to see is it possible to use the JS tracker to keep track those item, and using the same visitor_id (can be pass from frontend to backend API via header), I can use that same visitor_id and set it in php there, and php there can calculate the total cart amount, and paid order also.

I saw there is a few topic and this forum and the github there, discussing about hybird JS+php, a lot of people is arguing about GDPR and bot traffic, but I didnt see anyone really discussing the possibility of this solution is it really work or not.

Anyone have idea about this kind of implementation?