-
This repository adds a counter plugin to track site and page visits in the Craft CMS + Nuxt Starter.
-
Please note that this repository is provided as a sample and should not be used in production environments.
-
For more information please visit Craft CMS + Nuxt Starter.
This project assumes you have our recommended development environment DDEV installed and up-to-date.
-
Clone this repository, and move into the new directory:
git clone https://github.com/vnali/starter-nuxt-counter.git # ... cd starter-nuxt-counter
-
(Optional) Adjust the DDEV project name and domains. See this section for more information.
-
Set up your Craft CMS backend:
ddev composer install ddev craft install
Write down the username and password you choose, during installation. You’ll need it to log in to the control panel.
-
Generate a token for the Guestbook GraphQL Schema:
# Display a list of schemas and UUIDs: ddev craft graphql/list-schemas # Use the “Guestbook” schema ID to generate a token: ddev craft graphql/create-token c7d2eb61-cdde-4a76-88a9-eb30ddcf155b
-
Configure your frontend environment:
- Copy
frontend/.env.exampletofrontend/.env; - Update
GRAPHQL_TOKENto the token generated in the previous step; - Update
COUNTER_SECRET_TOKENto a complex token. - Update
headlessTokenin backend/config/counter.php to the value ofCOUNTER_SECRET_TOKENin the previous step.
- Copy
-
Install front-end dependencies:
ddev fe npm install
-
Start the Nuxt development server:
ddev fe npm run dev
-
Visit https://api.starter-nuxt-counter.ddev.site/admin and install the counter plugin.
-
Go to plugin settings and enable counter for your site at Site settings.
-
Optionally add widgets like visits, ... to the user dashboard
-
Visit frontend: https://starter-nuxt-counter.ddev.site/
- There is a statistics block in the footer of every page that shows the site and page visits for today.