@@ -18,15 +18,19 @@ This library can be installed via composer: `composer require visualappeal/matom
1818
1919### Create an instance of matomo
2020
21- require(__DIR__ . '/vendor/autoload.php');
21+ ``` php
22+ require(__DIR__ . '/vendor/autoload.php');
2223
23- use VisualAppeal\Matomo;
24+ use VisualAppeal\Matomo;
2425
25- $matomo = new Matomo('http://stats.example.org', 'my_access_token', 'siteId');
26+ $matomo = new Matomo('http://stats.example.org', 'my_access_token', 'siteId');
27+ ```
2628
2729There are some basic parameters (period, date, range) which you can define at the beginning. They do not change until you reset them with
2830
29- $matomo->reset();
31+ ``` php
32+ $matomo->reset();
33+ ```
3034
3135So you can execute multiple requests without specifying the parameters again.
3236
@@ -38,48 +42,62 @@ The ID of your website, single number, list separated through comma `"1,4,7"`, o
3842
3943The period you request the statistics for
4044
41- Matomo::PERIOD_DAY
42- Matomo::PERIOD_WEEK
43- Matomo::PERIOD_MONTH
44- Matomo::PERIOD_YEAR
45- Matomo::PERIOD_RANGE
45+ ``` php
46+ Matomo::PERIOD_DAY
47+ Matomo::PERIOD_WEEK
48+ Matomo::PERIOD_MONTH
49+ Matomo::PERIOD_YEAR
50+ Matomo::PERIOD_RANGE
51+ ```
4652
4753If you set the period to ` Matomo::PERIOD_RANGE ` you can specify the range via
4854
49- $matomo->setRange('2012-01-14', '2012-04-30'); //All data from the first to the last date
50- $matomo->setRange('2012-01-14', Matomo::DATE_YESTERDAY); //All data from the first date until yesterday
51- $matomo->setRange('2012-01-14'); //All data from the first date until now
55+ ``` php
56+ $matomo->setRange('2012-01-14', '2012-04-30'); //All data from the first to the last date
57+ $matomo->setRange('2012-01-14', Matomo::DATE_YESTERDAY); //All data from the first date until yesterday
58+ $matomo->setRange('2012-01-14'); //All data from the first date until now
59+ ```
5260
5361If you set it to something other than ` Matomo::PERIOD_RANGE ` you can specify the date via:
5462
55- $matomo->setPeriod(x);
56- $matomo->setDate('2012-03-03');
63+ ``` php
64+ $matomo->setPeriod(x);
65+ $matomo->setDate('2012-03-03');
5766
58- Case x of PERIOD_DAY the report is created for the third of march, 2012
59- Case x of PERIOD_WEEK the report is created for the first week of march, 2012
60- Case x of PERIOD_MONTH the report is created for march, 2012
61- Case x of PERIOD_YEAR the report is created for 2012
67+ Case x of PERIOD_DAY the report is created for the third of march, 2012
68+ Case x of PERIOD_WEEK the report is created for the first week of march, 2012
69+ Case x of PERIOD_MONTH the report is created for march, 2012
70+ Case x of PERIOD_YEAR the report is created for 2012
71+ ```
6272
6373### date
6474
6575Set the date via
6676
67- $matomo->setDate('YYYY-mm-dd');
77+ ``` php
78+ $matomo->setDate('YYYY-mm-dd');
79+ ```
6880
6981Or use the constants
7082
71- $matomo->setDate(Matomo::DATE_TODAY);
72- $matomo->setDate(Matomo::DATE_YESTERDAY);
83+ ``` php
84+ $matomo->setDate(Matomo::DATE_TODAY);
85+ $matomo->setDate(Matomo::DATE_YESTERDAY);
86+ ```
7387
7488Report for the last seven weeks including the current week
7589
76- $matomo->setPeriod(Matomo::PERIOD_WEEK);
77- $matomo->setDate('last7');
90+ ``` php
91+ $matomo->setPeriod(Matomo::PERIOD_WEEK);
92+ $matomo->setDate('last7');
93+ ```
7894
7995Report for the last 2 years without the current year
8096
81- $matomo->setPeriod(Matomo::PERIOD_YEAR);
82- $matomo->setDate('previous2');
97+ ```
98+ $matomo->setPeriod(Matomo::PERIOD_YEAR);
99+ $matomo->setDate('previous2');
100+ ```
83101
84102### segment, idSubtable, expanded
85103
@@ -89,32 +107,38 @@ For some functions you can specify `segment`, `idSubtable` and `expanded`. Pleas
89107
90108Specify a output format via
91109
92- $matomo->setFormat(Matomo::FORMAT_JSON);
110+ ``` php
111+ $matomo->setFormat(Matomo::FORMAT_JSON);
112+ ```
93113
94114JSON is converted with ` json_decode ` before returning the request.
95115
96116All available formats
97117
98- Matomo::FORMAT_XML
99- Matomo::FORMAT_JSON
100- Matomo::FORMAT_CSV
101- Matomo::FORMAT_TSV
102- Matomo::FORMAT_HTML
103- Matomo::FORMAT_RSS
104- Matomo::FORMAT_PHP
118+ ``` php
119+ Matomo::FORMAT_XML
120+ Matomo::FORMAT_JSON
121+ Matomo::FORMAT_CSV
122+ Matomo::FORMAT_TSV
123+ Matomo::FORMAT_HTML
124+ Matomo::FORMAT_RSS
125+ Matomo::FORMAT_PHP
126+ ```
105127
106128
107129## Example
108130
109131Get all the unique visitors from yesterday:
110132
111- require(__DIR__ . '/vendor/autoload.php');
133+ ``` php
134+ require(__DIR__ . '/vendor/autoload.php');
112135
113- use VisualAppeal\Matomo;
136+ use VisualAppeal\Matomo;
114137
115- $matomo = new Matomo('http://stats.example.org', 'my_access_token', 1, Matomo::FORMAT_JSON);
138+ $matomo = new Matomo('http://stats.example.org', 'my_access_token', 1, Matomo::FORMAT_JSON);
116139
117- $matomo->setPeriod(Matomo::PERIOD_DAY);
118- $matomo->setDate(Matomo::DATE_YESTERDAY);
140+ $matomo->setPeriod(Matomo::PERIOD_DAY);
141+ $matomo->setDate(Matomo::DATE_YESTERDAY);
119142
120- echo 'Unique visitors yesterday: ' . $matomo->getUniqueVisitors();
143+ echo 'Unique visitors yesterday: ' . $matomo->getUniqueVisitors();
144+ ```
0 commit comments