GA4 plugin results in ga4 + gtag + ads

  • Posts: 96
  • Thank you received: 5
  • Hikashop Business
4 months 2 weeks ago #359584

Hi,

My ads manager asked if i can ask how to perfect the plugin connection for sales details.
He mentioned it has probably to do with "datalayer" but i am not skilled at all.
Could someone skilled in the GA4 plugin and how it should work in GA4 and gtag/ads check my attachment to see why we only get "not set" results on all sales and how to specify in gtag/ga4 what kind of sales they actually are?
Kind regards.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
4 months 2 weeks ago #359589

Hi,

I don't know how that works either.
Looking online, it seems you could add view overrides to add extra javascript code to push events and data to GA:
developers.google.com/tag-platform/tag-manager/datalayer
I'm not sure.
Here ( stackoverflow.com/questions/14352440/how...-the-traffic-sources ) it says that you can configure GA to set the source of the events... Maybe that's what you should do ?

Your ads manager should know more about this than me.

Please Log in or Create an account to join the conversation.

  • Posts: 96
  • Thank you received: 5
  • Hikashop Business
4 months 2 weeks ago #359590

Thanks, can i email the builder of the plugin? As the one who made it surely must know what he made and thus understand what is either missing in my settings in ga4 to understand the plugin or what is missing in the plugin to fully push all the details.

Please Log in or Create an account to join the conversation.

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
4 months 2 weeks ago #359592

Hi,

I made that plugin myself. Still, what this plugin does is not directly linked to setting traffic sources.
The documentation I used to develop this plugin doesn't mention anything about the traffic source:
developers.google.com/analytics/devguide...ga4/set-up-ecommerce
developers.google.com/analytics/devguide...rce?client_type=gtag
This documentation doesn't mention any way for the plugin to be able to push what you want. It already pushes all the details which can be pushed as per the documentation there, as far as I know.

Please Log in or Create an account to join the conversation.

  • Posts: 96
  • Thank you received: 5
  • Hikashop Business
4 months 2 weeks ago #359603

Hi,

I checked some sources and discarded what could not be the problem, and i ended with this probability:
"Measurement protocol is not implemented correctly. The developer is sending events to GA4 without including a correct session_id. And if the event is sent to the past (up to 72 hours), then timestamp_micros parameter is not included (or it contains an incorrect value).

session_id parameter must contain a value of a session that was already tracked by GA4 on the website (client-side). If a developer randomly generates the session_id, the source/medium will be (not set).

If the event is sent to the past, the developer must include a valid session_id and it must include the timestamp (with timestamp_micros parameter) of when that session was actually happening on the site."

Is there a chance this is the issue in your opinion? Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
4 months 2 weeks ago #359636

Hi,

Thank you for your research on the matter. I think you're onto something here. I've been looking into this today.

session_id is not mentioned on the list of parameters of the "purchase" event in the GA documentation:
developers.google.com/analytics/devguide...ence/events#purchase
However, the page about sending events with the measurement protocol mentions it in passing:
developers.google.com/analytics/devguide...nts?client_type=gtag

In order for user activity to display in reports like Realtime, engagement_time_msec and session_id must be supplied as part of the params for an event.

However, it doesn't mention that it would affect the traffic source or anything.

Following this, I've stumbled on this page:
trackingchef.com/google-analytics/how-to...ent-protocol-events/
There, the author says that the session_id is necessary to connect the conversions with the user visits. So it might be what's missing indeed.
It also provides a payload example and a method to get the session_id with raw javascript.
Now, the code proposed there directly extract that from the cookies and requires the stream id. That's not ideal.
Searching further on this, I found this:
stackoverflow.com/questions/26915432/how...-by-google-analytics
Which provides the gtag code to get the session_id. That's actually the same mechanism the plugin already uses to get the client_id, which is another information the plugin has to provide when using the measurement protocol.

Now, this doesn't mean that it will fix the "traffic source" issue. I didn't see a mention of this so far. So I searched further and I found this:
stackoverflow.com/a/75500170
So here, passing the session_id indeed seems to be the solution to the missing source.

So, to make it short, I think that with this I can cook up something so that the session_id is provided by the plugin when using the measurement protocol to notify GA of the purchases. It's a shame that GA doesn't properly document this. We all waste so much time on this.

Anyways. With all that in mind, I've been working on adding this to the plugin and I just made a new release for it:
www.hikashop.com/marketplace/product/108...egration-google.html
Please try it and let me know how it goes.

The following user(s) said Thank You: NicoW

Please Log in or Create an account to join the conversation.

  • Posts: 96
  • Thank you received: 5
  • Hikashop Business
4 months 2 weeks ago #359637

Thanks so much for taking this seriously and research as deep as you did.
You do great work!

I already installed your update and as GA4 is slow as a snail, i will let you know only next week.

You are indeed right that google isn't taking these things as serious as they make it for us to implement, researching this i've seen experts complain about functions randomly not working and never getting updated/fixed and the time of processing data is only getting slower even though their test stream shows it can be delivered in real time. Google being google i guess...

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

  • Posts: 96
  • Thank you received: 5
  • Hikashop Business
4 months 1 week ago #359682

Hi Nicolas,

Unfortunately the new update did not resolve the issue yet.
Would/could it matter if i uninstall the old plugin before installing the new plugin?
Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
4 months 1 week ago #359683

Hi,

No, it won't matter. Check the "order_payment_params" of the new orders in the database. You should have the "session_id" in there.
Is that the case ?
Also, if you activate the "debug" setting of the GA plugin, once a new order is purchased, and provided that you configured the plugin with your measurement API secret, GA will log the communication between HikaShop and GA via the measurement protocol in the "payment log file" accessible in the HikaShop configuration. So you'll be able to confirm whether the session_id is passed to GA or not and if GA provides an error or not.

I'm suspecting that the session_id is provided to GA now, and that the problem is elsewhere (like in a configuration to make in the GA account).

Please Log in or Create an account to join the conversation.

  • Posts: 96
  • Thank you received: 5
  • Hikashop Business
4 months 1 week ago #359742

Yes, it seems like client_id is indeed fine and i see no errors:
BluePsyduck\Ga4MeasurementProtocol\Request\Payload Object
(
[clientId] => 787889507.1710273916
[userId] =>
[timestampMicros] =>
[userProperties] => Array
(
)

[nonPersonalizedAds] =>
[events] => Array
(
[0] => BluePsyduck\Ga4MeasurementProtocol\Request\Event\PurchaseEvent Object
(
[currency] => EUR
[transactionId] => D1L8T34
[value] => 34.95
[affiliation] =>
[coupon] =>
[shipping] => 0
[tax] => 6.07
[items] => Array
(
[0] => BluePsyduck\Ga4MeasurementProtocol\Request\Event\Item Object
(
[itemId] => 6011431748786_O
[itemName] => Lightbenders Oranje zwart
[affiliation] =>
[coupon] =>
[currency] => EUR
[creativeName] =>
[creativeSlot] =>
[discount] =>
[index] => 0
[itemBrand] =>
[itemCategory] => "UV400 filter brillen"
[itemCategory2] => "Alles"
[itemCategory3] =>
[itemCategory4] =>
[itemCategory5] =>
[itemListId] =>
[itemListName] =>
[itemVariant] =>
[locationId] =>
[price] => 34.95
[promotionId] =>
[promotionName] =>
[quantity] => 1
)

)

[session_id] => 1710273915
[engagement_time_msec] => 1
)

)

)

Hope any new ideas pop up, don't wish to need to go back to my developer to code this into hikashop for 300usd just to make it work. Thanks already.

Please Log in or Create an account to join the conversation.

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
4 months 1 week ago #359745

Hi,

The debug you provided indicate that the session_id is passed to GA.
So if you don't see what you want on GA, then it means that the problem is not with this.
As for the session_id, I'm happy to add other improvements to the plugin if there is something missing in the data sent by it.
What would be missing ? I don't know. Maybe nothing is missing and it had nothing to do with the session_id in the first place ? Maybe it needs to configuration in your GA account ? I don't know.
I can only follow what the GA documentation recommends and if nothing is written about something, I can't guess it. We are already grasping at straws with the session_id.

Please Log in or Create an account to join the conversation.

  • Posts: 96
  • Thank you received: 5
  • Hikashop Business
4 months 1 week ago #359768

I've hired a ga4 gtm expert, hope he can figure it out. Thanks.

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

  • Posts: 96
  • Thank you received: 5
  • Hikashop Business
4 months 2 days ago #359922

Hi, as the proper setting of analytics and tagmanager made some changes, the expert is still thinking about it since 'some' is far from 'all'.

Meanwhile another GA4 question:
There is a strange issue going on where there are multiple google tag manager codes in my website code.
John from Jextensions! looked (because we are working on GDPR plugin) and my website developer looked especially in the template but we think we have only 1 tagmanager code in Gantry page settings and no other tagmanager plugins running. Yet there are multiple tagmanager codes running.
So the question is, would the GA4 plugin somehow be able to make this happen by it's connection with ga4+tagmanager?
I would guess no, but i wouldn't find out without asking.

Please Log in or Create an account to join the conversation.

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
4 months 2 days ago #359925

Hi,

There are two javascript files:
- For GA4, you have this file : www.googletagmanager.com/gtag/js
The GA4 plugin we developed adds it to the pages automatically.
I can see it is also added by something else on your website, right at the end of the pages. This is not necessary and could be deactivated.
- For tag manager, you have this file: www.googletagmanager.com/gtm.js
Our GA4 plugin doesn't add it to the pages. Yet, you have it added to your pages twice somehow.

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum