Make the module more flexible for custom overrides

Created on 27 August 2024, 3 months ago

Problem/Motivation

I've been using this module for a while, and each time, I have to override it because every project requires different data in their gtag events, especially when dealing with commerce events.

I noticed that all the classes handling event functionalities are restricted from being overridden due to the use of the final attribute on these classes.

If you want to alter the event data (for example, adding coupons, an item category, a brand name, etc.), you have to define a custom event (and a custom subscriber) that reuses the google_tag code. Another solution is to directly patch the module to override the final class.

Until now, I didn't consider this a significant problem, but with a recent project, I had to make a considerable number of modifications to the commerce events and global events. Initially, I tried to manage these modifications with a custom patch, but I realized that this approach would be difficult to maintain in the long term.

I found a related issue that aligns with mine. It is somewhat similar...

Proposed Resolution

It would be beneficial to remove the final attribute from the subscriber and event classes to make this module more flexible for custom modifications. These changes would make it easier for developers to override google_tag.

I'm also writing this issue to gather more information about this code structure. While I understand the rationale behind using the final class attribute, it significantly limits the ability to enhance the module to meet custom needs.

Another completely different solution would be to enhance the admin interface and the configuration forms by adding more granular configuration options for each event’s data.

What do you think about this topic?

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France t.maquin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @t.maquin
  • 🇬🇧United Kingdom newaytech

    Hi there. I'd love to see a way of elegantly extending the events. Current use case is around search - I want to pass a custom metric of results returned - so we can then spot internal search that is resulting in no terms found.

    I've also applied some changes via local patches - but not yet gone to the extent of defining a custom evet...

    Would you be able to share an overview of how this hangs together please - it may help to provide a way out in the short term. Does the code sit in an external module - dependant upon Google_Tag ?

    Thanks for a great module - it's serving us well.

Production build 0.71.5 2024