Introduction
Use the Prefetch API to get and record page visits count across your site.
Getting started
To get started:
- First register your domain by passing your email address through our API. This email will be used for verification purposes.
- Once your domain is verified, you can specify a list of valid pages where the pageviews counter will be active.
- After setting valid pages list, use our increment api to integrate the pageviews counter on your site.
You could use our npm package to do the integration. The package provides a hook that automatically increments the counter and returns the current page view count.
Getting count
Request
GET
/v1/pageviews/page-id-1/valuecurl -X GET "https://prefetch.io/api/v1/pageviews/page-id-1/value" \
-H "Authorization: {{token}}"
Response
{
"count": 177
}
Increment count
Request
POST
/v1/pageviews/page-id-1/incrementcurl -X POST "https://prefetch.io/api/v1/pageviews/page-id-1/increment" \
-H "Content-Type: application/json" \
-d '{"token": "{{token}}"}'
Response
{
"count": 178
}
Guides
Configure
Learn how to programmatically configure pass list of pages on which the api will work.
Steps
Register
First step starts with registering a client to get a unique clientId and clientSecret for each domain.
Configure
Learn about the configure api which is used to restrict pages on which increment can be called.
Increment
Learn about the increment api which is used to increment the pageviews counter using the token.