Title: wrong idSite
Last modified: May 30, 2021

---

# wrong idSite

 *  Resolved [Manuel22](https://wordpress.org/support/users/manuel22/)
 * (@manuel22)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/wrong-idsite/)
 * Hello, please help … 😉
    what was done until now: Matomo update from 4.2 to 4.3
   somehow crashed and let to an white screen of death. I renamed the Matomo folder
   and got my site up again. After that I reinstalled Matomo without problems but
   now my tracking data was not shown anymore. I deleted all Matomo related files
   and database tables. I installed Matomo again and uploaded a database backup 
   of the Matomo tables. Still data was not shown. I did some digging in the database
   and settings and found out that before the crash all data was saved in the database
   with idSite: 1
 * Now Matoma tells me in the diganostic tab that my idSite is 2.
    * Matomo Version:
   4.2.1 * Matomo Blog idSite: 2 * Matomo Install Version: 4.2.0 (Install date: 
   2021-05-30 20:37:10)
 * Question: How do I change this idSite back to 1?
 * Thank you for any hint 🙂

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Plugin Author [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14500636)
 * Hey [@manuel22](https://wordpress.org/support/users/manuel22/)
 * sorry about the trouble. To find out whether the data for idSite 1 is still there
   you would need to execute below query. This requires access to your database 
   and that you know how to execute a MySQL query. Would that work for you?
 * In below queries I assume your WordPress DB table prefix is `wp_`. If that’s 
   not the case you might have to adjust the queries to your WordPress table prefix.
   Let me know if you need help finding out that value (it would be shown in the
   [Matomo System Report](https://matomo.org/faq/wordpress/how-do-i-find-and-copy-the-system-report-in-matomo-for-wordpress/)).
 *     ```
       select idvisit from wp_matomo_log_visit where idsite = 1 limit 1;
       ```
   
 * If this query returns a result then the data is still there. In that case you
   could try if this makes the previously tracked data show up again:
 *     ```
       update wp_options set option_value=1 where option_name = 'matomo-site-id-1';
       ```
   
 * If this doesn’t work yet then you might need to execute the next query also:
 *     ```
       update wp_matomo_site set idsite=1 where idsite = '2';
       ```
   
 * Does this help [@manuel22](https://wordpress.org/support/users/manuel22/) ?
 *  Thread Starter [Manuel22](https://wordpress.org/support/users/manuel22/)
 * (@manuel22)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14500679)
 * Thank you.
    Data is still here, I already knew this from my backup. I’ll try 
   out the rest tomorrow. I was not aware that Matomo also has information in wp_options.
 *  Plugin Author [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14500706)
 * Glad the data is still there [@manuel22](https://wordpress.org/support/users/manuel22/)
   Let me know how it goes and I’ll be happy to help.
 *  Thread Starter [Manuel22](https://wordpress.org/support/users/manuel22/)
 * (@manuel22)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14514177)
 * Hi, yes it helped. Thank you.
    But there’s still somewhere a siteid=2 in the 
   data.
 * When I open the summary tab Matomo shows me all the data from previous months
   etc. So this is correct now.
    But when I open the “reports” page or “tag manager”,
   I still get an error message:
 * > An unexpected website was found in the request: website id was set to ‘2’.
 * I already searched for this in the db, but probably you can tell me faster where
   to look 😉
    -  This reply was modified 4 years, 12 months ago by [Manuel22](https://wordpress.org/support/users/manuel22/).
 *  Plugin Author [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14514230)
 * [@manuel22](https://wordpress.org/support/users/manuel22/) glad to hear it’s 
   partially working. I wonder if the information is maybe still cached. Could you
   go to Matomo Analytics -> Diagnostics -> Troubleshooting tab and click there 
   on “Clear cache”? If that’s the problem, it would eventually also resolve itself
   automatically.
 *  Thread Starter [Manuel22](https://wordpress.org/support/users/manuel22/)
 * (@manuel22)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14519727)
 * clearing the cache unfortunately didn’t help.
 *  Plugin Author [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14530586)
 * [@manuel22](https://wordpress.org/support/users/manuel22/) when you click on 
   the reporting link, can you let me know what URL it opens afterwards? Feel free
   to remove your domain but the path be useful. I’d just like to check if it mentions
   idSite 1 or idSite 2 there. I looked in the code and it should be using the idSite
   1 ( as configured in `wp_options` table).
 *  Thread Starter [Manuel22](https://wordpress.org/support/users/manuel22/)
 * (@manuel22)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14536012)
 * The strange thing (and I noticed already before), indeed it shows idSite=1.
    
   [https://example.de/wp-content/plugins/matomo/app/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday](https://example.de/wp-content/plugins/matomo/app/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday)
 * But the site still shows me this error message:
 * > An error occurred
   >  An unexpected website was found in the request: website 
   > id was set to ‘2’ .
    -  This reply was modified 4 years, 11 months ago by [Manuel22](https://wordpress.org/support/users/manuel22/).
 *  Plugin Author [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14539153)
 * Does the entire page say that or is the page loading partially?
 * Any chance you could create another user in your WordPress (for example an administrator)
   and see if the same error happens there?
 * Sorry it’s taking a while. It’s one of those things that’s very likely very quick
   to find out when you have access to WordPress and the database but hard to know
   what it might be otherwise.
 *  Thread Starter [Manuel22](https://wordpress.org/support/users/manuel22/)
 * (@manuel22)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14573012)
 * I had other things to do, but here we go now… It looks like this:
    [https://ibb.co/K9rxscf](https://ibb.co/K9rxscf)
 * And indeed: With another user it works as expected. There I don’t get this error
   message.
 *  Plugin Author [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14577039)
 * Thank you for the screenshot [@manuel22](https://wordpress.org/support/users/manuel22/)
   This helps. Could you add the following line to your wp-config.php?
 * `define('PIWIK_PRINT_ERROR_BACKTRACE', true);`
 * I think then we should be able to see the trace that leads to this error and 
   understand things better. The screen should basically change slightly and show
   a few file names and line numbers.
 *  Thread Starter [Manuel22](https://wordpress.org/support/users/manuel22/)
 * (@manuel22)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14580398)
 * Thats the new stuff:
 * Stack trace
 * #0 /home/example.com/public_html/wp-content/plugins/matomo/app/plugins/SitesManager/
   API.php(244): Piwik\Site::setSiteFromArray()
    #1 /home/example.com/public_html/
   wp-content/plugins/matomo/app/core/Site.php(480): Piwik\Plugins\SitesManager\
   API->getSiteFromId() #2 /home/example.com/public_html/wp-content/plugins/matomo/
   app/core/Site.php(520): Piwik\Site::getFor() #3 /home/example.com/public_html/
   wp-content/plugins/matomo/app/plugins/Dashboard/Menu.php(25): Piwik\Site::getNameFor()#
   4 /home/example.com/public_html/wp-content/plugins/matomo/app/core/Menu/MenuTop.
   php(55): Piwik\Plugins\Dashboard\Menu->configureTopMenu() #5 /home/example.com/
   public_html/wp-content/plugins/matomo/app/core/Plugin/Controller.php(681): Piwik\
   Menu\MenuTop->getMenu() #6 /home/example.com/public_html/wp-content/plugins/matomo/
   app/core/Plugin/Controller.php(606): Piwik\Plugin\Controller->setGeneralVariablesViewAs()#
   7 /home/example.com/public_html/wp-content/plugins/matomo/app/plugins/CoreHome/
   Controller.php(173): Piwik\Plugin\Controller->setGeneralVariablesView() #8 /home/
   example.com/public_html/wp-content/plugins/matomo/app/plugins/CoreHome/Controller.
   php(207): Piwik\Plugins\CoreHome\Controller->getDefaultIndexView() #9 [internal
   function]: Piwik\Plugins\CoreHome\Controller->index() #10 /home/example.com/public_html/
   wp-content/plugins/matomo/app/core/FrontController.php(615): call_user_func_array()#
   11 /home/example.com/public_html/wp-content/plugins/matomo/app/core/FrontController.
   php(167): Piwik\FrontController->doDispatch() #12 /home/example.com/public_html/
   wp-content/plugins/matomo/app/core/dispatch.php(32): Piwik\FrontController->dispatch()#
   13 /home/example.com/public_html/wp-content/plugins/matomo/app/index.php(25):
   require_once(‘/home/ff-eic…’) #14 {main}
 *  Plugin Author [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14580971)
 * Great thanks. I now fully understand the problem.
 * Executing below queries in your database should make this work again. Please 
   note in the last query you need to replace `$USERNAME` with your WordPress username:
 *     ```
       DELETE from wp_matomo_site where idsite = '2';
       DELETE FROM wp_matomo_option where option_name like '%_defaultReport';
       DELETE FROM wp_matomo_access where idsite = 2;
       INSERT INTO wp_matomo_option (option_name, option_value, autoload)
       VALUES ('$USERNAME_defaultReport', '1', 0);
       ```
   
 * The last query may not be needed. I checked in the code and usually if the site
   was deleted this problem would not happen. It’s only happening because the site
   IDs were changed manually.
 * Let me know if this helps [@manuel22](https://wordpress.org/support/users/manuel22/)
 *  Plugin Author [Thomas](https://wordpress.org/support/users/tsteur/)
 * (@tsteur)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14678536)
 * Hi [@manuel22](https://wordpress.org/support/users/manuel22/) have you had a 
   chance to look at my last comment? I’ll mark this issue for now as resolved due
   to inactivity but happy to follow up if there’s still an issue. Simply comment
   in that case.
 *  Thread Starter [Manuel22](https://wordpress.org/support/users/manuel22/)
 * (@manuel22)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14707937)
 * Hi, thank you.
 * I forgot about this issue a little bit. But just now I managed to fix it.
    I 
   didn’t follow your instructions completely because I was a bit afraid of deleting
   multiple %_defaultReport entries. But this finally pushed me in the right direction
   and I found the one entry “wp_admin_defaultReport” which showed a “2” in the 
   values. I just changed it to “1” and now everything works as expected again.
 * Thank you very very much 🙂
    -  This reply was modified 4 years, 10 months ago by [Manuel22](https://wordpress.org/support/users/manuel22/).

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘wrong idSite’ is closed to new replies.

 * ![](https://ps.w.org/matomo/assets/icon-256x256.png?rev=3531741)
 * [Matomo Analytics - Powerful, Privacy-First Insights for WordPress](https://wordpress.org/plugins/matomo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/matomo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/matomo/)
 * [Active Topics](https://wordpress.org/support/plugin/matomo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/matomo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/matomo/reviews/)

 * 15 replies
 * 2 participants
 * Last reply from: [Manuel22](https://wordpress.org/support/users/manuel22/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/wrong-idsite/#post-14707937)
 * Status: resolved