matomo-org / plugin-Migration

Migrate a Matomo Measurable (website, app, roll-up, ...) from one Matomo instance to another Matomo
5 stars 11 forks source link

Migration and site IDs #25

Closed TRILOS closed 4 years ago

TRILOS commented 4 years ago

When installing the Matomo plugin for WordPress, a record is being created for the site in wp_matomo_site table with idsite=1. Using Migration plugin in Matomo 3.14.0, the data from a site with id 2 is being imported into the WordPress datababase, but a second site in the target database with idsite=2 is being created and all data is referring to that ID 2. The Matomo plugin for WordPress seems to expect a site with ID 1 and we can switch to site ID 2 in the Dashboard, but this is not nice to do this every time. And the plugin seems no to be able to handle only 1 site in wp_matomo_site table with any other ID than 1 (it leads to a fatal error). So it seems to be necessary to provide a target-site-id paramater for the console migration command. And I like to know whether I can change the cross linking reference from the default site to the data in the WordPress database to prevent the user from changing the site in the Dashboary every time.

tsteur commented 4 years ago

Hi @TRILOS

I just realise we're actually not really supporting this as mentioned in https://matomo.org/faq/wordpress/how-do-i-migrate-all-my-data-from-matomo-on-premise-to-matomo-for-wordpress/ but we should have made this more clear in the readme etc.

I've documented some background in https://github.com/matomo-org/plugin-Migration/issues/26 and also provided a query to link the new site. This query should do the trick:

update wp_options set option_value = 2 where option_name = "matomo-site-id-1"
TRILOS commented 4 years ago

Hi @tsteur , as I understood, the Migration plugin is dedicated and officially recommended to migrate also to Matomo for WP. And this scenario here shows the conditions: WP Plugin installation creates site ID. So the Migration solution should be aware of different source and target site IDs. Anyway, the SQL statement uses an option with does not exist in wp_options or wp_matomo_option. The question is, where the site ID setting for Matomo for WP plugin is...

tsteur commented 4 years ago

The option should be there @TRILOS any chance you are using WP Multisite mode?

TRILOS commented 4 years ago

@tsteur , no, the WP site in this case is no Multisite. I have searched for applicable columns and values and did not find anything.

tsteur commented 4 years ago

@TRILOS I checked again and the mapping should be stored in the options table if you are not using MultiSite.

image

If Multisite was enabled, it would store it likely in a wp_sitemeta table but this table should not even exist if you aren't using multisite.

Matomo isn't looking somewhere else for the mapped idSite. If it's not stored there, technically the plugin should not even really work for you. Is there any chance you can check again? And if it's not there can you maybe post your system report?

The report should be anonymised but you could also email us at wordpress at matomo.org