Templating
The plugin registers a craft.clickyAnalytics Twig variable so you can read the same analytics that power the dashboard from your own templates, whether front end or control panel.
Quick examples
{# Visitors online right now #}
{{ craft.clickyAnalytics.visitorsOnline }}
{# Top 10 pages over the last 7 days #}
{% for page in craft.clickyAnalytics.topPages('last-7-days', 10) %}
{{ page.title }}: {{ page.value }}
{% endfor %}
{# Recent visitors feed #}
{% for v in craft.clickyAnalytics.recentVisitors('today', 20) %}
{{ v.geolocation }}: {{ v.landingPath }} ({{ v.ago }})
{% endfor %}Guard reads when credentials may be missing:
{% if craft.clickyAnalytics.isConfigured %}
{{ craft.clickyAnalytics.visitorsOnline }} online
{% endif %}Date expressions
Methods take a Clicky date expression as their first argument. The values used throughout the plugin are:
today, yesterday, 2-days-ago, last-7-days, last-14-days, last-28-days, last-60-days, last-90-days.
Available methods
All ranked methods take (date = 'last-7-days', limit = 10) unless noted.
| Method | Returns |
|---|---|
isConfigured | Whether a Site ID and Sitekey are configured. |
visitorsOnline | The number of visitors online now (int). |
overview(date) | Headline tallies: visitors, actions, bounce rate, average time |
topPages(date, limit) | Most-visited pages. |
topSources(date, limit) | Top traffic sources. |
topReferrers(date, limit) | Top referring domains. |
topSearchEngines(date, limit) | Searches grouped by engine. |
topCountries(date, limit) |
Visitors by country (with ISO code). |
topCities(date, limit) | Visitors by city. |
topRegions(date, limit) | Visitors by region. |
topBrowsers(date, limit) | Web browsers. |
topOperatingSystems(date, limit) | Operating systems. |
topDevices(date, limit) | Hardware device types. |
topScreenResolutions(date, limit) | Screen resolutions. |
entryPages(date, limit) | Landing pages. |
exitPages(date, limit) | Exit pages. |
topDownloads(date, limit) | Downloaded files. |
topGoals(date, limit) | Goal completions. |
topCampaigns(date, limit) | Campaign performance. |
recentVisitors(date, limit) |
Recent individual visits (limit defaults to 12). |
pageStats(href, date, visitorLimit) |
Analytics for a single page path (date defaults to last-90-days, visitorLimit to 5). |
Per-page stats
{% set stats = craft.clickyAnalytics.pageStats(entry.url, 'last-28-days') %}
{{ stats.visitors }} visitors, {{ stats.unique }} unique, {{ stats.time }} avg.Theming helpers
If you're building your own dashboards, you can match the plugin's colour scheme and reuse its bundled SVG assets:
| Method | Returns |
|---|---|
primaryColor | The primary accent hex for the active scheme. |
accent(role) |
The accent hex for a widget role (e.g. accent('sources')). |
pieColors | The pie-slice palette (array of hex strings). |
secondaryColor | The secondary accent hex (the New vs Returning donut's second slice). |
softFillColor | The soft pastel fill hex (the Overview chart's area fill). |
rankBarColors | The four rank-tint hexes (array), used to shade ranked-list rows by position |
assetUrl(path) |
Published URL for a bundled asset, e.g. assetUrl('flags/ie.svg'). |
<span style="color: {{ craft.clickyAnalytics.primaryColor }}">
<img src="{{ craft.clickyAnalytics.assetUrl('browsers/chrome.svg') }}" alt="Chrome" width="16">
</span>