So I’ve been moving a Sitecore website to a live server, and one of the problems I had was that the analytics database already had data in it. The MongoDB instance was new, so that was empty – but how do I clear our test/development data out of the Analytics database?
Well it turns out that there is a stored procedure – __DeleteAllReportingData – in the Analytics database for just that:
Run that, and all your data will be gone. Obviously, use with care – but useful.
It seems to work by removing all foreign keys, truncating each table, and adding the keys back, so the user running this will need permission to do all these things.
Also, you can exclude tables, but I just ran it with the input of an empty string ( ” ) to clear all.
4 thoughts on “Clearing Sitecore Analytics data”
Can you clear data prior to a certain date?
I’m not sure, but I don’t think so.
This is not working as expected for me.
I’ve still got all the contacts etc…
Anyone else have issue with this?
Contacts are stored in Mongo, assuming you’re using Sitecore 7.5-8.2. You’ll have to delete the repository there, too. The instructions in this article will only clear aggregate data in the reporting database.