Product
 • 
3 Mins

Anomify WordPress Plugin

Posted on
January 23, 2023
Check out our demos

See Anomaly detection, matching and learning in action.

Live Demos

You don't need to work for a tech company or have massive amounts of complex data in order to benefit from Anomify's anomaly detection. Anything which produces regular time-series data can potentially be used to deliver metrics for analysis.

Indeed, one of the goals in our development of Anomify has been to allow easy integration with common and varied data sources.

A case in point is WordPress. There are an estimated 60 million websites running on WordPress. This includes many business websites, and WordPress is an important tool for business owners - for their corporate websites, for e-commerce, portfolios and more.

Due to its ubiquity, WordPress is also a major target for spammers and hackers, which can put those businesses at risk.

We decided to integrate Anomify with WordPress, so that we could quickly be alerted to any unusual behaviour on our own WordPress site.

WordPress allows for third-party plugins to be developed and made available on its plugin repository, so we started by creating a skeleton plugin which allowed a blog owner to enter their Anomify API key via the WordPress dashboard, and was then able to communicate with the Anomify service.

Next we needed some metrics to send. We started by creating metrics from a few native WordPress events. Due to its extensive set of hooks, it's easy for a plugin to monitor events in WordPress's code in real time. Our plugin can then create metric names from these, and pass them to our service.

We added some basic metrics about posts, comments, logins and errors generated from the WordPress PHP code - for example "login.success", "login.fail", "comment.added", and so on. We registered the related WordPress hooks to send these metrics.

The plugin automatically prefixes each of these metric names with the address of the WordPress site, so that multiple sites can be connected without fear of mixing up their data. For example, "wordpress.anomify.ai.login.fail".

The initial native WordPress metrics we set up were:

  • content.comment.added.approved
  • content.comment.added.spam
  • login.fail
  • login.success
  • php.exception

When installed on a volunteer’s website, this was immediately helpful in letting the owner know that the site was getting regular spikes of failed login attempts, which is a common attempt at hacking a WordPress site.

An Anomify Slack alert. For security reasons, the real domain name of the site has been hidden.

This insight prompted the owner to check that everyone with a WordPress login had a secure password. They also ensured that these hardening measures were in place on the site.

We looked at other commonly-used WordPress plugins which generate useful data and wanted to see if we could create and send metrics about those to Anomify too. 

We looked at WP Statistics and then WooCommerce.

WP Statistics collates standard website activity statistics for WordPress bites, and WooCommerce is an open-source eCommerce solution created by Automattic, the makers of WordPress.

Both of these plugins generate data, and our plugin can convert that data into metrics, send it to Anomify, and allow the blog owners to be alerted to any unusual activity happening with their site traffic or WordPress shop activity.

Examples of metrics generated for WP Statistics:

  • visitor.new
  • visitor.returning
  • visitor.country.{country_code} e.g. visitor.country.us
  • visitor.device.{device_type} e.g. visitor.device.mobile

Examples of metrics generated for WooCommerce:

  • cart.added
  • cart.emptied
  • cart.updated
  • customer.created
  • customer.deleted
  • customer.password.reset
  • order.cancelled
  • order.created
  • payment.complete

We've also made it easy for developers of other WordPress plugins to create their own metrics and send them via the Anomify plugin, and given some code examples in our plugin's documentation. With our plugin installed, a single line of code can update a metric from any point in your own plugin.

The Anomify WordPress plugin is available from wordpress.org/plugins/anomify/ and the free tier of the Anomify service allows you to send up to 1,000 different metrics. You can sign up for an account at anomify.ai

Simon Holliday

Want to check that we're a good fit?