GoogleTagManagerBundle icon indicating copy to clipboard operation
GoogleTagManagerBundle copied to clipboard

If persist any kind of redirect, the data is lost

Open alexkingdom opened this issue 3 years ago • 6 comments

Seems this bundle doesn't care about situation when for example user paid something and we redirect to success page. I think we need to use something like flash messages in symfony that will show one time the data.

What do you think ?

alexkingdom avatar Sep 18 '21 20:09 alexkingdom

What do you mean? Can you explain a bit more your issue or use case? And where do you think that the bundle should cover this task?

xyNNN avatar Sep 20 '21 10:09 xyNNN

@xyNNN I will try to explain, think about situation when someone buy a ticket from your site. How it's look like:

  1. Click button buy
  2. Post request to payment endpoint (not ajax)
  3. We make all checks if user have enough money
  4. In case of success of point 3, we set data layer something like: $googleTagManager->addPush(['purchase' => 'ticket', 'amount' => 125.50]);
  5. Redirect to success page

And on success page we don't have this data layer with these data. Hope you understood me. Below you will find just small piece of code.

image

alexkingdom avatar Sep 20 '21 13:09 alexkingdom

Sorry @alexkingdom for this delay. Currently I'm very busy myself and don't find time to investigate your issue. Perhaps you could please debug it yourself to identify your problem and that I'm willed to help you to merge this pull request ASAP and create a new bugfix release for you!

xyNNN avatar Oct 11 '21 11:10 xyNNN

Will make more deep investigation but later. Now too busy :(

alexkingdom avatar Oct 29 '21 09:10 alexkingdom

@alexkingdom - Do you mean GA4 purchase event with attributes: https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm#make_a_purchase_or_issue_a_refund should be triggered on success page?

kristjan-kure avatar May 20 '23 14:05 kristjan-kure

@alexkingdom I think it makes more sense that you make sure the right attributes are injected into GTM on the actual success page. I don't think this library should persist things to a next pageview as everyone's use case is different.

E.g. I do similar to you on the confirmation page in a project. I store the Order ID in the session, then I use that Order ID on the success page to pull the data I need, clear the session and inject it into GTM.

stefandoorn avatar May 21 '23 08:05 stefandoorn