br33f / php-GA4-Measurement-Protocol

PHP GoogleAnalytics4 Measurement Protocol Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set User ID (User Parameters)?

blazejstarosta opened this issue · comments

I'm trying to add user_id tracking into my app, but I'm not sure how I can send it with this library. I've tried adding it on the event itself, but then it's being sent as event param, not as a user property.

example:

$addToCartEventData
->setUserId($user_id)

I think it needs to be added to the baseRequest, but I don't see it documented. Could you tell me please, how can I pass it alongside the client_id to the whole hit?

EDIT:

Figured it out, sorry for the fuss.

$baseRequest
->setUserId($user_id)

So easy and logical, yet sometimes you need to write it down for yourself. :D

commented

Glad you found the solution :)