Closed JoostWan closed 1 year ago
@JoostWan You can set any data to an event object:
$eventName = 'example_event';
$anyEventData = new BaseEvent($eventName);
$anyEventData
->setMethod('Twitter')
->setContentType('Post')
->setItemId('example_item_id')
->setAnyParamYouWish('test'); // means 'any_param_you_wish' is set
So you can set both session_id and timestamp parameter this way.
Alternatively, if you wish not to use PHP magic methods, you can set params explicitly by calling:
$anyEventData->setParamValue('param_name', 'param_value');
Hope it helps.
@br33f Thanks!
@JoostWan Hey, I am currently solving exactly the same problem, all my conversions are being attributed as "direct" even though most of them should come from "Paid" and "Organic".
Can I ask if I have to send the whole value of the cookie with the 2 letters in the beginning?
For example for _ga, should it be GA1.1.1938356095.1686127670 or just 1.1.1938356095.1686127670
Same for ga
Thanks for reply.
@Luxato you could check our conversation here to see how you get those properties: https://github.com/br33f/php-GA4-Measurement-Protocol/issues/33
@basepack Thank you. I actually found this video where all required parameters are explained in detail. https://www.youtube.com/watch?v=r_eoeU2qUn0
But I still can't attribute them with the correct sessions, every conversion is still "direct" ffs. Have you eventually made it run @basepack ?
@Luxato You have use : $eventData->setParamValue('session_id', 'session-id-here'); Or $eventData->setSessionId('session-id-here'); ?
@Fnizou Yes, I am using this
if (strpos(($browserData['ga4_session_id'] ?? ''), '.') !== false) {
$parts = explode(".", $browserData['ga4_session_id']);
$ga4_session_id = $parts[2]; // Output: 1686042977
}
$purchaseEventData->setParamValue('session_id', $ga4_session_id);
@Luxato I will try on my side in the next few days,
can you try to force the typing: $purchaseEventData->setParamValue('session_id', (int)$ga4_session_id);
I have already had a problem with the transaction_id being raised because of this,
we stay informed
@Luxato on my side I just set up this, and I think "session_id" it's a (string) and not (int),
if( !is_null($row['id_session_ga4']) ){ $purchaseEventData->setParamValue('session_id', (string)$row['id_session_ga4']); }
I wait 24 hours
I've been investigating my data in BigQuery. It seems like it gets there fine. But when I tried to search by client id, there are no prior events. Then I checked other events and I've noticed that the client id is encoded.
Whereas my conversions have format taken from the cookie
Any ideas why it's being encoded?
Found this setting in the GTM server container :P, the client id is not being encoded anymore
Hi, I have the same problem: in the "User acquisition" report, purchases are correctly attributed to the various channels, while in the "Traffic acquisition" report, all conversions are attributed to the "Unassigned" channel group. I realized the reason is that I set setClientId() but not setSessionId().
However, I didn't understand how to extract the Session ID value. Can you help me please? Thank you
I don't know if this is an issue or a wrong call on our side. But we used this package from e-commerce system Magento. When a payment is made we send a call to the measurement protocol. We saved also the
client_id
to the order. When we do the call to the measurement protocol we send also the client ID. Conversion is visible in GA4 but it's not matched with an existing sessie. Did some research and found some information on this site;How we can set the Session ID and timestamp with this package to send this data with the client id to the measurement protocol.
https://www.simoahava.com/analytics/session-attribution-with-ga4-measurement-protocol/