Hello folks! I am having a very strange issue with...
# support
e
Hello folks! I am having a very strange issue with Rudderstack-PHP --> GA4 integration. The events seem not to be accepted to GA4 (does not show up in Realtime report) and are stored in the Rudderstack buffer (rt_jobs_1 Postgres table). An event with identical payload and authentication details that I try sending through the GA hit builder (https://ga-dev-tools.google/ga4/event-builder/) reaches GA4 successfully. Any ideas on what may be wrong?
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
b
can you please share a sample transformed payload you are sending to GA4 via rudderstack?
e
sure, it's: {"body": {"XML": {}, "FORM": {}, "JSON": {"events": [{"name": "first_payment_added", "params": {"amount": 1210, "currency": "EUR"}}], "user_id": 0, "client_id": "11ea8cbf-4efd-4f5b-a89b-a24a70d53851", "timestamp_micros": 1685087468000000}, "JSON_ARRAY": {}}, "type": "REST", "files": {}, "method": "POST", "params": {"api_secret": "FRv2ja4BQwS3AmEBkYv6DA", "measurement_id": "G-LFLJLSCC73"}, "userId": "", "headers": {"HOST": "www.google-analytics.com", "Content-Type": "application/json"}, "version": "1", "endpoint": "https://www.google-analytics.com/debug/mp/collect"}
I'm now looking at the payload and seeing the DEBUG endpoint of google-analytics.com/ - I guess it may be an answer.
b
yes, it is the answer
🙌 1
turn off debug view toggle
e
I've removed the toggle, but the Rudderstack-PHP sent events are still not coming to GA4. The PHP library generates such request to Rudderstack: curl -u '2PrzK8PqaICT5xHVJbpchklHUQT': -X POST -H 'Content-Type: application/json' -d '{"batch":[{"userId":111,"event":"promo_added_fork_curl","properties":{"amount":11,"currency":"EUR"},"context":{"library":{"name":"rudder-analytics-php","version":"2.0.1","consumer":"ForkCurl"}},"timestamp":"2023-05-26T135534+03:00","messageId":"9d250aa7-9a29-4164-8977-3123b8f31a1f","channel":"server","type":"track"}],"sentAt":"2023-05-26T135534+03:00"}' 'https://ra.cherryservers.com/v1/batch' -H 'User-Agent: rudder-analytics-php/2.0.1' > /dev/null 2>&1 & While I can see such payload stored on Rudderstack's postgres buffer (I suppose the eventual payload is taken from this table row): 974 | 1yAyUsxsk8YBjMsAoktxHIzax9J | 995e35c1-a393-4d30-bb2d-4da7c52b0b15 | <<>>111 | {"record_id": null, "source_id": "2PrzK8wU7mLHp1ClQ0DI0kWD3pe", "event_name": "promo_added_fork_curl", "event_type": "track", "message_id": "f9f56af4-9f77-4365-8a0d-18b52f1d2ecf", "received_at": "2023-05-26T103931.402Z", "workspaceId": "1yAyUsxsk8YBjMsAoktxHIzax9J", "transform_at": "processor", "source_job_id": "", "destination_id": "2HtzrNuX8ORn0Ov5jVUVAD8bYyH", "gateway_job_id": 473871, "source_task_id": "", "source_batch_id": "", "source_category": "", "source_job_run_id": "", "source_task_run_id": "", "source_definition_id": "1k7JZrvZQ7OPBAnHzogYIpansx2", "destination_definition_id": ""} | GA4 | {"body": {"XML": {}, "FORM": {}, "JSON": {"events": [{"name": "promo_added_fork_curl", "params": {"amount": 11, "currency": "EUR"}}], "user_id": 111, "client_id": "f9f56af4-9f77-4365-8a0d-18b52f1d2ecf", "timestamp_micros": 1685097575000000}, "JSON_ARRAY": {}}, "type": "REST", "files": {}, "method": "POST", "params": {"api_secret": "FRv2ja4BQwS3AmEBkYv6DA", "measurement_id": "G-LFLJLSCC73"}, "userId": "", "headers": {"HOST": "www.google-analytics.com", "Content-Type": "application/json"}, "version": "1", "endpoint": "https://www.google-analytics.com/mp/collect"} | 1 | 2023-05-26 103935.55362 | 2023-05-26 103935.55362
b
why are you using batch endpoint?
GA4 does not support batching, you have to use
v1/track
endpoint
e
I cannot find an option how to change the endpoint when using rudder-php library. I guess it's the defualt endpoint. Any ideas?
b
can you change
<https://ra.cherryservers.com/v1/batch>
to
<https://ra.cherryservers.com/v1/track>
e
Where should I set it when using the PHP library? Is it during the SDK initialization?
b
Copy code
Rudder::track(array(
  "userId" => "f4ca124298",
  "event" => "Article Bookmarked",
  "properties" => array(
    "title" => "Snow Fall",
    "subtitle" => "The Avalanche at Tunnel Creek",
    "author" => "John Branch"
  )
));
are you following this syntex to fire events
e
It seems so: \Rudder\Rudder::track( [ 'userId' => $clientId, 'event' => 'first_payment_added', 'properties' => [ 'amount' => $amount, 'currency' => $currency ] ] );
b
can you remove array and try it
\Rudder\Rudder::track( 'userId' => $clientId, 'event' => 'first_payment_added', 'properties' => [ 'amount' => $amount, 'currency' => $currency ] );
e
The result is still the same. The SDK does not act differently.
b
let me ask my fellow engineers, will update you soon
one suggestion : can you convert
userId
to string and try again
🙌 1
GA4 does not accepts int userId
e
Thanks, converting userId into a string has helped!