Control Panel Analytics Widgets

Statami v3 Packagist Sponsor Sponsor

A Laravel Analytics widget collection for Statamics Control Panel.

While the code is open-source, it's important to remember that you'll need to purchase a license before using this addon in production. Licenses cost $5 and can be purchased from the Statamic Marketplace.

Installation

Install via the Control Panel or via composer

composer require phpsa/statamic-analytics

Configuration

Follow these instructions to get your ANALYTICS_VIEW_ID,

save the json file to storage/app/analytics/service-account-credentials.json

Environmental variables

PHPSA_SA_TRACKING_ID= -- this is your ga tracking id
PHPSA_SA_ANONYMIZE_IP -- boolean sets the anonymizeIp varaible
PHPSA_SA_ASYNC -- boolean whether to use async loading
PHPSA_SA_DISPLAY_FEATURES -- boolean Use Display Features if enabled
PHPSA_SA_BEACON -- boolean  Set tracking to beacon in browsers that support it
PHPSA_SA_TRACK_UID -- boolean track users
PHPSA_SA_IGNORE_ADMINS -- boolean do not track admins
PHPSA_SA_DEBUG -- boolean
PHPSA_SA_TRACE_DEBUGGING -- boolean
PHPSA_SA_DISABLE_SENDING -- boolean

Tag

you can inject the analytics tracking code by using the following tag in your layout file

{{ga}}

Enable Widgets

Currently we have 5 widgets available, more will be added based on feedback / requests. To enable a widget edit the config/statamic/cp.php file and add your widget requirement into the widgets section: the following are available:

Type Group Additional parameters
analytics totalVisitorsAndPageViews days (default 10)
analytics topReferrers days (default 7) max_results (default 10)
analytics mostVisitedPages days (default 7) max_results (default 10)
analytics topBrowsers days (default 7) max_results (default 10)
analytics topcountries days (default 7)

eg:

[
    'type' => 'analytics',
    'group' => 'totalVisitorsAndPageViews',
    'width' => 50,
    'days' => 10,
    'display' => 'table'
]

Graph choices:

  • bar
  • line
  • pie
  • doughnut

Screen Shots

Advanced Docs