- Posts: 36
- Thank you received: 2
Issue with GA4 server-side purchase events
1 year 8 months ago #365246
by jcamus
Issue with GA4 server-side purchase events was created by jcamus
-- HikaShop version -- : 5.1.1
-- Joomla version -- : 4.4.3
Hi,
I am a developer on www.winescholarguild.com
We are using Hikashop GA4 plugin and we only have server-side events turned on.
"Purchase event in Javascript" is disabled.
We recently noticed a lot of transactions (about 20-30%) are missing in GA4, so I addded logging to understand what is happening.
It appears that many orders are skipped because of this reason:
no client_id in order XXXX
Can you please advise on how to fix this?
Thanks
-- Joomla version -- : 4.4.3
Hi,
I am a developer on www.winescholarguild.com
We are using Hikashop GA4 plugin and we only have server-side events turned on.
"Purchase event in Javascript" is disabled.
We recently noticed a lot of transactions (about 20-30%) are missing in GA4, so I addded logging to understand what is happening.
It appears that many orders are skipped because of this reason:
no client_id in order XXXX
Can you please advise on how to fix this?
Thanks
Please Log in or Create an account to join the conversation.
1 year 8 months ago - 1 year 8 months ago #365247
by nicolas
Replied by nicolas on topic Issue with GA4 server-side purchase events
Hi,
Thanks for your feedback.
The debug message you're providing is something I added to the GA plugin in case the client_id was missing in the order in order to skip sending the purchase event to GA because GA would refuse the event without a client_id.
I didn't put much more thought into it.
Also, the plugin has a mechanism to get the client_id from the javascript of GA during the checkout and store it inside the order when the order is being created, at the end of the checkout.
This way, GA can link the purchase event with the activity of the user on the website.
Now, it is possible the client_id is missing. For example, if you use the "new" button of the orders listing in the backend in order to manually enter an order, then there won't be a client_id for it.
So, I've looked a bit online about it and found this nice page explaining the issue and providing some possible solutions:
stackoverflow.com/questions/68773179/wha...nalytics-4-using-the
So, based on this, I think that instead of the "return" just after the line:
hikashop_writeToLog('no client_id in order '.$orderData->order_id);
in the file plugins/system/hikashop_ga4/hikashop_ga4.php, I think you want to have :
$payload->clientId = $orderData->order_id;
That way, instead of skipping the purchase event, it will use the order_id as client_id and proceed with the purchase event.
I've implemented the change on our end with a new version of the plugin.
Thanks for your feedback.
The debug message you're providing is something I added to the GA plugin in case the client_id was missing in the order in order to skip sending the purchase event to GA because GA would refuse the event without a client_id.
I didn't put much more thought into it.
Also, the plugin has a mechanism to get the client_id from the javascript of GA during the checkout and store it inside the order when the order is being created, at the end of the checkout.
This way, GA can link the purchase event with the activity of the user on the website.
Now, it is possible the client_id is missing. For example, if you use the "new" button of the orders listing in the backend in order to manually enter an order, then there won't be a client_id for it.
So, I've looked a bit online about it and found this nice page explaining the issue and providing some possible solutions:
stackoverflow.com/questions/68773179/wha...nalytics-4-using-the
So, based on this, I think that instead of the "return" just after the line:
hikashop_writeToLog('no client_id in order '.$orderData->order_id);
in the file plugins/system/hikashop_ga4/hikashop_ga4.php, I think you want to have :
$payload->clientId = $orderData->order_id;
That way, instead of skipping the purchase event, it will use the order_id as client_id and proceed with the purchase event.
I've implemented the change on our end with a new version of the plugin.
Last edit: 1 year 8 months ago by nicolas.
The following user(s) said Thank You: jcamus
Please Log in or Create an account to join the conversation.
Time to create page: 0.284 seconds