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.

Getting count

Request

GET
/v1/pageviews/page-id-1/value
curl -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/increment
curl -X POST "https://prefetch.io/api/v1/pageviews/page-id-1/increment" \
  -H "Content-Type: application/json" \
  -d '{"token": "{{token}}"}'

Response

{
  "count": 178
}

Guides

Register

Learn how to get clientId and clientSecret.

Read more

Configure

Learn how to programmatically configure pass list of pages on which the api will work.

Read more

Token

Read about the why we need to request a token and how to request it.

Read more

Increment

Understand how to increment pageviews counter and how to display the count.

Read more

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.

Token

Learn about the token api which is used to ensure only valid page views are captured.

Increment

Learn about the increment api which is used to increment the pageviews counter using the token.

Was this page helpful?