fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
486 stars 301 forks source link

matomo integration: custom tracking code #4842

Closed HB9HIL closed 1 year ago

HB9HIL commented 1 year ago

Hello guys

Would it be possible to let the administrator edit the matomo/piwik tracking manually? In the settings for the matomo plugin the tracking code is auto-generated but in case of some custom options it would be nice to give the admin a option to edit the tracking code manually.

Thanks for discussing this.

Cheers

fisharebest commented 1 year ago

You do not say what changes you want.

Either they are:

a) configuration options that would be useful for many Matomo users

b) specific changes for your own site.

If (a), then maybe we could add other configuration options. If (b), then you could simply use the CSS/JS module - which allows you to add your own JS to every page.

HB9HIL commented 1 year ago

I mean a)

some more configuration options.

image

As I mentioned, for example the possibility to use a custom tracking code of more configuration options. Why? Because the automatic generated tracking code uses "piwik.php" for the tracking engine after the main URL. The newer version of Matomo uses 'matomo.php'.

This is why the tracking in my case doesn't work.

fisharebest commented 1 year ago

the automatic generated tracking code uses "piwik.php"

I don't see piwik.php anywhere.

Perhaps show me the exact changes you've made / want to make?

HB9HIL commented 1 year ago
image

The Tracking code generated by webtrees doesn't work like that. But webtress do not allow to edit the tracking code manually.

HB9HIL commented 1 year ago

I don't see piwik.php anywhere.

See Line 9

And there are some more differences

HB9HIL commented 1 year ago

Perhaps show me the exact changes you've made / want to make?

The easiest solution would be to don't generate the matomo code automatically. Instead let the user paste in the tracking code generated by matomo.

SunsetGolfer commented 1 year ago

Perhaps show me the exact changes you've made / want to make?

The easiest solution would be to don't generate the matomo code automatically. Instead let the user paste in the tracking code generated by matomo.

Is this possible now? Would be really nice...

HB9HIL commented 1 year ago

Perhaps show me the exact changes you've made / want to make?

The easiest solution would be to don't generate the matomo code automatically. Instead let the user paste in the tracking code generated by matomo.

@fisharebest Any Update on that?

@SunsetGolfer Unfortunaltely not.. Matomo does not work

HB9HIL commented 1 year ago

@SunsetGolfer

A workaround for you

Go to file resources/views/modules/matomo-analytics/snippet.phtml

comment out (or delete) the script from Line 12 to Line 24

Copy your matomo tracking code from Matomo into that file.

For me it works. I can't understand why the script is hardcoded and generated by webtrees. This is really bad.

HB9HIL commented 1 year ago

@SunsetGolfer

new matomo tracking code
SunsetGolfer commented 1 year ago

@HB9HIL Thanks, will try that tomorrow...

fisharebest commented 1 year ago

For me it works. I can't understand why the script is hardcoded and generated by webtrees. This is really bad.

webtrees provides two modules:

1) "CSS and JS". This allows you to insert your snippet on every page. You can insert content into both the <head> and <body> elements.

2) "Matomo/Piwik analytics" which generates the snippet automatically. This module is designed for users who want it to "just work", and are not confident to edit javascript. The JS snippet was created using the documentation from Matomo.

You said that you didn't want to use the standard snippet, because you wanted to customise it with additional tracking parameters. The "CSS and JS" module is perfect for you!

HB9HIL commented 1 year ago

For me it works. I can't understand why the script is hardcoded and generated by webtrees. This is really bad.

webtrees provides two modules:

  1. "CSS and JS". This allows you to insert your snippet on every page. You can insert content into both the <head> and <body> elements.
  2. "Matomo/Piwik analytics" which generates the snippet automatically. This module is designed for users who want it to "just work", and are not confident to edit javascript. The JS snippet was created using the documentation from Matomo.

You said that you didn't want to use the standard snippet, because you wanted to customise it with additional tracking parameters. The "CSS and JS" module is perfect for you!

And I said the automatic generated tracking does not work with the latest version of matomo😉

fisharebest commented 1 year ago

And I said the automatic generated tracking does not work with the latest version of matomo😉

I missed that bit. A consequence of discussing two things in the same issue...

HB9HIL commented 1 year ago

@SunsetGolfer

A workaround for you

Go to file resources/views/modules/matomo-analytics/snippet.phtml

comment out (or delete) the script from Line 12 to Line 24

Copy your matomo tracking code from Matomo into that file.

For me it works. I can't understand why the script is hardcoded and generated by webtrees. This is really bad.

Nevermind I found a workaround