|
1 | | -GoatCounter doesn’t store the domain a pageview belongs to; if you add |
2 | | -GoatCounter to several (sub)domains then there’s no way to distinguish between |
3 | | -requests to `a.example.com/path` and `b.example.com/path` as they’re both |
4 | | -recorded as `/path`. |
| 1 | +GoatCounter *does*, optionally, store the domain a pageview belongs to; |
| 2 | +If the log importer script is run with `$host` in the log format, or uses a |
| 3 | +format that includes that, such as `combined-vhost`, `common-vhost`, `bunny`. |
5 | 4 |
|
6 | | -This might be improved at some point in the future; the options right now are: |
| 5 | +Currently, javascript api `count.js`, does not support doing this. |
7 | 6 |
|
8 | | -1. Create a new site for every domain; this is a completely separate site which |
9 | | - has the same user, login, etc. You will need to use a different site for |
10 | | - every (sub)domain. |
| 7 | +To report a host via the raw API include the `host` field within the `hits` list, such as: |
11 | 8 |
|
12 | | -2. If you want everything in a single overview then you can add the domain to |
13 | | - the path, instead of just sending the path: |
14 | | - |
15 | | - <script> |
16 | | - window.goatcounter = { |
17 | | - path: function(p) { return location.host + p } |
18 | | - } |
19 | | - </script> |
20 | | - {{template "code" .}} |
21 | | - |
22 | | - For subdomains it it might be more useful to just add the first domain label |
23 | | - instead of the full domain here, or perhaps just a short static string |
24 | | - identifying the source. |
25 | | - |
26 | | - |
27 | | -Also see [setting the endpoint in JavaScript]({{.Base}}/code/modify#setting-the-endpoint-in-javascript-4). |
| 9 | +``` |
| 10 | +curl -X POST "$api/count" \ |
| 11 | + -H 'Content-Type: application/json' \ |
| 12 | + -H "Authorization: Bearer $token" \ |
| 13 | + --data '{"no_sessions": true, "hits": [{"host": "example.org", "path": "/one"}]}' |
| 14 | +``` |
0 commit comments