Closed uehler closed 5 years ago
Hello uehler,
you accurately described one of the major hurdles when it comes to developing plugins for Shopware. The usual solution to this problem is to use the cache-breaking widget controllers. As you may know, I recently added a feature to add modules for custom dataLayers. I just released a new version that now supports widget controllers as custom modules.
In the following example we want to track the first name of the logged in customer. As a "carrier" for dataLayer push we will use the checkout/info
endpoint. First, make sure that the endpoint is not being cached. So possibly remove from widgets/checkout
controller from the cached controller list. Add a new module with the key widgets_checkout_info
. Afterwards you can go ahead and configure the dataLayer for the new module. To get an idea of the variables you can use within the dataLayer see the template of the endpoint under themes/Frontend/Bare/widgets/checkout/info.tpl
The dataLayer push for widget views will be prepended directly before the corresponding markup, so it possibly won't be part of the first push within the head
tag but will appear wherever the widget was inserted. I hope this helps.
I won't upload that new version the Shopware Community Store just now. It would help a lot if you would be willing to give this a try first and tell me if this version solved the issue.
ok great, we will test it on monday and give you feedback
Hi @dneustadt,
I just tested your changes and it looks good so far, but there are a lot of executions of the window.dataLayer.push on detail and listing (screen from detail)
In our custom theme its even worse.
I did the same steps like you and tested Shopware 5.2.27 with custom theme based on the bootstrap theme and Shopware 5.3.7 with default theme
Thanks for the feedback. I just drafted a new release (still 3.2.0) that includes according changes. That should fix the issue with identical dataLayer tags being prepended on multiple Widget PostDispatch events.
yes, that problem is fixed
thank you very much!
if you create a tag, which tracks personal data on cached pages, you will track wrong data.
detail page for example: If you are the first customer, your personal data will be added to the tag. Because the page is cached, the tag with your data is also cached and will be served to all customers who load that page. If the first customer is not logged in, the tag will track empty data for all page views.
Is there any chance to track dynamic data with this tag manager?