matomo-org / tag-manager

Free Open Source Matomo Tag Manager - A simple way to manage and maintain all of your (third-party) tags on your website.
https://matomo.org
GNU General Public License v3.0
170 stars 58 forks source link

Allow user to set disableAlwaysUseSendBeacon to prevent ping request and getting blocked by uBlock #581

Closed Orgoth closed 1 year ago

Orgoth commented 1 year ago

At the moment it is not possible to set disableAlwaysUseSendBeacon to prevent ping requests. This causes adblockers to prevent tracking.

Auswahl_004 Auswahl_003 Auswahl_002

sghiel from matomo tracker was kind enough to point me to this repository. https://github.com/matomo-org/matomo/issues/19864#issuecomment-1340640583

Do you possibly have a suggestion for a workaround that I can set the parameter? Currently, only alwaysUseSendBeacon can be set in the interface.

Thank you very much in advance.

Orgoth commented 1 year ago

As a temporary solution I have changed two files.

Template/Variable/MatomoConfigurationVariable.php

            $this->makeSetting('disableAlwaysUseSendBeacon', false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
                $field->title = Piwik::translate('TagManager_MatomoConfigurationMatomoDisableAlwaysUseSendBeaconTitle');
                $field->description = Piwik::translate('TagManager_MatomoConfigurationMatomoDisableAlwaysUseSendBeaconDescription');
            }),

Template/Tag/MatomoTag.web.js

                    if (matomoConfig.disableAlwaysUseSendBeacon) {
                        tracker.disableAlwaysUseSendBeacon();
                    }

Translation is missing, but not necessary for the usage. TagManager_MatomoConfigurationMatomoDisableAlwaysUseSendBeaconTitle and TagManager_MatomoConfigurationMatomoDisableAlwaysUseSendBeaconDescription

snake14 commented 1 year ago

Hi @Orgoth . Thank you for taking the time to create this issue. Probably the easiest workaround would be to, in your Matomo Tag Manager dashboard, create a Custom HTML tag and call the disableAlwaysUseSendBeacon tracker method in that.

Thank you. Your second comment looks like a good improvement suggestion. I will add this issue to our list of issues to be prioritised by our product team.

EPNW-Eric commented 1 year ago

So, the "temporary solution" seems pretty solid, why didn't you open a PR?

Orgoth commented 1 year ago

I had a silent hope that it would be adopted by contributors or authors since it is such a simple and easy customization.

Another point was still, currently there is the following point in the system. "MatomoConfigurationMatomoAlwaysUseSendBeaconTitle": "Always use sendBeacon", With the introduction of my workaround, the end user would question why there is the additional item to disable. If he has disabled the first entry "Always use sendBeacon"?! "unchecked"

The other side is then still the effort with all the points that must be met for the contribution before.

Review

snake14 commented 1 year ago

Thank you @Orgoth for creating that PR. It was been merged and will be included in the next Matomo 5.x release.