WP Manifestindependent plugin directory
manifest / analytics / wordpress-plugin-analytics

Micro SaaS for WordPress Plugin Analytics

A Micro SaaS analytics dashboard for tracking downloads, version updates, error logs, user feedback, and license management for your plugins.

by Umang Prajapati · github.com/umang48/wordpress-plugin-analytics · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/umang48/wordpress-plugin-analytics/archive/refs/heads/main.zip

A Micro SaaS analytics dashboard for tracking downloads, version updates, error logs, user feedback, and license management for your plugins.

Description

This plugin serves as your self-hosted Micro SaaS Dashboard for all your WordPress plugins. It provides a REST API to track downloads, log errors, collect feedback, and verify licenses seamlessly, offering a beautiful admin dashboard to monitor all metrics with rich modern aesthetics.

How to use the Tracking API in your other plugins:

Below are code snippets you can drop into the other WordPress plugins you develop, to send data directly to this dashboard.

1. Track Downloads (Run on Plugin Activation)

function tracking_saas_track_download() {
    $api_url = 'https://YOUR_SAAS_DOMAIN.com/wp-json/wp-plugin-analytics/v1/track/download';
    wp_remote_post( $api_url, array(
        'body' => json_encode( array(
            'plugin_slug' => 'my-awesome-plugin',
            'version'     => '1.0.0',
        ) ),
        'headers' => array( 'Content-Type' => 'application/json' ),
        'blocking' => false,
    ) );
}
register_activation_hook( __FILE__, 'tracking_saas_track_download' );

2. Track Errors (Hook into PHP exceptions or custom logger)

function tracking_saas_track_error( $error_message, $stack_trace ) {
    $api_url = 'https://YOUR_SAAS_DOMAIN.com/wp-json/wp-plugin-analytics/v1/track/error';
    wp_remote_post( $api_url, array(
        'body' => json_encode( array(
            'plugin_slug'   => 'my-awesome-plugin',
            'version'       => '1.0.0',
            'error_message' => $error_message,
            'stack_trace'   => $stack_trace,
            'wp_version'    => get_bloginfo( 'version' ),
            'php_version'   => phpversion()
        ) ),
        'headers' => array( 'Content-Type' => 'application/json' ),
        'blocking' => false,
    ) );
}

3. Verify License

function tracking_saas_verify_license( $license_key ) {
    $api_url = 'https://YOUR_SAAS_DOMAIN.com/wp-json/wp-plugin-analytics/v1/license/verify';
    $response = wp_remote_post( $api_url, array(
        'body' => json_encode( array(
            'license_key' => $license_key,
            'domain'      => $_SERVER['HTTP_HOST']
        ) ),
        'headers' => array( 'Content-Type' => 'application/json' ),
    ) );

    if ( ! is_wp_error( $response ) ) {
        $body = json_decode( wp_remote_retrieve_body( $response ), true );
        if ( isset( $body['status'] ) && $body['status'] === 'valid' ) {
            return true;
        }
    }
    return false;
}

Installation

  1. Upload the plugin folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Navigate to the new 'Plugin Analytics' menu item in your dashboard to view insights
  4. Integrate the API snippets into your developed plugins to start sending data!