Created
July 25, 2013 16:25
-
-
Save sashtown/6081392 to your computer and use it in GitHub Desktop.
Piwik stats: Display unique visitors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// this token is used to authenticate your API request. | |
// You can get the token on the API page inside your Piwik interface | |
$token_auth = 'your_fancy_piwik_token'; | |
$url = "http://stats.your-domain.com/"; | |
$url .= "?module=API&method=VisitsSummary.getUniqueVisitors"; | |
$url .= "&idSite=1&period=week&date=today"; | |
$url .= "&format=PHP"; | |
$url .= "&token_auth=$token_auth"; | |
$fetched = file_get_contents($url); | |
// More stuff: http://piwik.org/docs/analytics-api/reference/ | |
?> | |
<!-- Display stats --> | |
<p><?php echo unserialize($fetched); ?> unique visitors this week.</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment