Welcome to the Page Views Counter project! This project aims to track the number of views each page receives.
I've implemented a page view counter using Netlify Blobs and Netlify Functions, allowing us to monitor page view efficiently.
- Objective: Track page views.
- Implementation: Implemented an API with Netlify Functions and store view counts using Netlify Blobs Service.
- Usage Instructions:
- Send a GET Request: Send a GET request to the API endpoint with the URL of the page to track.
- Receive Response: Receive the response containing the page URL and its view count.
- Display View Count: Display the view count on your page as needed.
-
Endpoint:
https://page-views-counter.netlify.app/page_view?page=https://example.com/index.html/
-
Method: GET
-
Request Parameters:
page
(URL of the page to track) -
Sample Request:
curl https://page-views-counter.netlify.app/page_view?page=https://example.com/index.html/
-
Sample Response:
{ "data": { "page_url": "https://example.com/index.html/", "view_count": 8, "last_modified": "2024-05-11T06:41:00.557Z" } }
The API response includes the page URL and its corresponding view count in JSON format.
-
Clone Repository: Clone this repository to your local machine:
git clone https://github.com/kananinirav/page-views-counter.git
-
Install Netlify CLI: Install the Netlify CLI if you haven't already. This CLI tool allows you to interact with Netlify services from your command line.
-
Install Dependencies: Navigate to the project directory and install the dependencies:
cd <project_directory> npm install
-
Start Server: Start the server locally using the Netlify CLI:
netlify dev