kernl/power-analytics

A PHP & WordPress library for sending analytics data to WP Power Analytics

1.3.0 2022-02-11 11:45 UTC

This package is auto-updated.

Last update: 2024-04-11 16:11:12 UTC


README

This is the WP Power Analytics PHP library for integrating with WordPress.

The current version is 1.3.0

Usage

Initialize the library as early as possible in your plugin or theme code.

require plugin_dir_path( __FILE__ ) . "includes/power_analytics.php";
$powerAnalyticsUUID = "Your Power Analytics Product UUID";
$MyPlugin_PowerAnalytics = new WordPressPowerAnalytics(
    $powerAnalyticsUUID,
    __FILE__,
    "your-plugin-slug"
);
$MyPlugin_PowerAnalytics->initialize();

Event Tracking

global $MyPlugin_PowerAnalytics;
$MyPlugin_PowerAnalytics->track($eventName, $eventValue);

Why the "MyPlugin_" in the instance variable?

It's likely that other plugins a user has installed will use WP Power Analytics. To avoid collisions, try to explicitly namespace your WordPressPowerAnalytics instance variable.