• Resolved israel5ew

    (@israel5ew)


    WooCommerce has suddenly stopped generating an Analytics Report.

    Please see the attached image: https://snipboard.io/K4RiWS.jpg

    To bring context to this issue, we had a DDOS attack on the previous date. In order to counter the attack, I blocked all bots with some exception via robots.txt and .htaccess.

    Coincidentally, the date I blocked the bots is the same date the report stopped working.

    What is the best course of action to this?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    Thanks for sharing the details and the screenshot.

    The WooCommerce Analytics system doesn’t rely on search engine bots, so changes in your robots.txt file wouldn’t normally affect it. However, since you also mentioned updating your .htaccess rules during the DDoS attack, it’s possible that some of those rules are unintentionally blocking the requests WooCommerce uses to record or query order data.

    Here are a few steps you can try:

    1. First clear the Analytical cache by going to WooCommerce > Status > Tools and running the Clear Analytics Cache tool. 
    2. Re-import historical data: Go to WooCommerce → Analytics → Settings and try running the “Import historical data” process again.
    3. Review your .htaccess rules – Make sure none of the rules are blocking REST API requests (/wp-json/…) or WooCommerce Admin endpoints, as these are needed for Analytics.

    If you still face the same issue, I’d like to understand your site properly. Please share with us the necessary information below for us to investigate the issue further:

    • System Status Report which you can find via WooCommerce > Status
    • Fatal error logs (if any) under WooCommerce > Status > Logs.

    Please use https://pastebin.com/ or https://gist.github.com/ and share a link to that paste in reply here. Once we have more information, we’ll be able to assist you further.

    Thread Starter israel5ew

    (@israel5ew)

    Hi,

    I tried unblocking the REST API in the .htaccess file but however the analytics page has entirely stopped working.

    I undo the script and ran a status report. Here’s the pastebin link: https://pastebin.com/Gce2sRC4

    In case you might need this, here’s our .htaccess: https://pastebin.com/WcmbZPEG

    Thank you

    Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @israel5ew,

    I understand how disruptive this is—especially right after mitigating a DDoS. Your status report and .htaccess point to your security rules as the most likely reason Analytics stopped working.

    What’s going on (short version)

    WooCommerce Analytics needs the WordPress REST API and background (cron) requests to fetch/query data. Your custom .htaccess bot rules are blocking many non-browser user agents (e.g., WordPress/…) and possibly REST paths, so the Analytics app can’t load or import.

    Quick fixes to try (in order):

    1. Temporarily disable your custom bot block to confirm
    • In .htaccess, comment out the entire block between:
    # Allow Only Verified Search Engine Bots ...
    ...
    # END (right before “# BEGIN WordPress”)
    • Save, clear any server/CDN cache, then reload Analytics → Overview. If it loads, we’ve confirmed the cause.
    1. If you want to keep bot blocking, add safe allow-rules Add these above your bot rules (so they run first):
    # --- Allow REST API & admin-ajax for WP/Woo ---
    RewriteCond %{REQUEST_URI} ^/wp-json/ [OR]
    RewriteCond %{REQUEST_URI} ^/wp-admin/admin-ajax\.php$
    RewriteRule .* - [L]
    
    # --- Allow WordPress/Woo background requests by UA ---
    RewriteCond %{HTTP_USER_AGENT} (WordPress|WooCommerce|WooCommerce\sAdmin|WooCommerce\sREST) [NC]
    RewriteRule .* - [L]

    Then remove or relax this line (it blocks anything that doesn’t contain “Mozilla”):

    RewriteCond %{HTTP_USER_AGENT} !Mozilla [NC]

    If you keep it, add exceptions (as above), or it will keep blocking WP/Woo background jobs.

    1. Reset Analytics data caches
    • WooCommerce → Status → Tools → Clear Analytics Cache
    • WooCommerce → Analytics → Settings → Import historical data (re-run)
    1. Check that REST works
    1. Run pending background tasks
    • WooCommerce → Status → Scheduled Actions Filter for wc_admin_* and run a few due/pending items to kickstart processing.
    1. Temporarily disable cache/security layers (test)
    • Turn off WP Rocket and SiteGround Security Optimizer briefly to rule out additional blocking/minification while testing Analytics.

    If the page still won’t load, please open your browser dev tools on Analytics → Overview and share:

    • A screenshot of the Console tab (any errors)
    • The Network tab for failed requests (paths like /wp-json/wc-analytics/… and their response codes)

    Once we see that (plus the updated .htaccess), we can advise the minimal permanent rules to keep your bot protection without breaking Analytics.

    Thread Starter israel5ew

    (@israel5ew)

    Hi @lovingbro ,

    1. Upon removing the bot blocking script and resetting the cache, Analytics were able to fetch data. This implies that the bot blocking script is the cause of this issue.
    2. Adding the script quoted above results to an error. Please see the screenshot: https://snipboard.io/LryCBo.jpg
    3. The REST is working: https://shop.5ew.com.au/wp-json
    4. This is the error I got from the console: https://snipboard.io/aUK4R1.jpg

    Thanks

    Hi @israel5ew,

    Thank you for getting back to me and for sharing the clarification. Since the analytics data worked correctly once the bot script was removed, it suggests that analytics itself is functioning properly and that the script block is the main issue.

    I reviewed the screenshot you shared and noticed the same errors appearing after applying the script my colleague suggested. I also took a look at your .htaccess file and can see there are already quite a few rules in place.

    While we could continue suggesting rules for compatibility, this approach isn’t ideal as it could lead to conflicts later on. Because of this, and since it falls outside the scope of our support, I’d recommend reaching out to an expert through Codeable.io. They’ll be able to dive into your site, review the script you’re trying to block, go through your .htaccess, and provide a cleaner solution that preserves both your analytics data and your site’s normal operation.

    Please don’t hesitate to let me know if you have any other questions.

    Thread Starter israel5ew

    (@israel5ew)

    Hi,

    I have discarded the recommended script and proceeded with my old script for now.

    Thank you

    Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @israel5ew,

    Thank you for the update. Since you’ve decided to continue with your old script for now, I’ll go ahead and mark this thread as resolved.

    If you have a moment, we’d greatly appreciate it if you could leave us a review here: https://wordpress.org/support/plugin/woocommerce/reviews/#new-post — it really helps us improve and support more store owners like you.

    All the best with your site going forward!

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

The topic ‘Reporting Not Working’ is closed to new replies.