{"id":16363404,"url":"https://github.com/leggetter/with-posthog","last_synced_at":"2026-05-19T07:31:50.481Z","repository":{"id":137878631,"uuid":"336917127","full_name":"leggetter/with-posthog","owner":"leggetter","description":"An example of using PostHog for analytics with a Next.js application","archived":false,"fork":false,"pushed_at":"2021-02-10T13:29:40.000Z","size":1476,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-22T21:21:15.799Z","etag":null,"topics":["analytics","analytics-tracking","nextjs","nextjs-example","posthog","posthog-cloud"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leggetter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-08T00:00:55.000Z","updated_at":"2021-02-10T13:29:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"65a4aee2-db1d-4b73-ae4d-f6c3b13ebd2e","html_url":"https://github.com/leggetter/with-posthog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leggetter/with-posthog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggetter%2Fwith-posthog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggetter%2Fwith-posthog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggetter%2Fwith-posthog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggetter%2Fwith-posthog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leggetter","download_url":"https://codeload.github.com/leggetter/with-posthog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leggetter%2Fwith-posthog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000780,"owners_count":26082851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","analytics-tracking","nextjs","nextjs-example","posthog","posthog-cloud"],"created_at":"2024-10-11T02:27:28.045Z","updated_at":"2025-10-08T22:16:14.427Z","avatar_url":"https://github.com/leggetter.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"An example of using [PostHog](https://posthog.com) for analytics with a [Next.js](https://nextjs.org/) application.\n\n## Deploy your own\n\n[Sign up for a PostHog Cloud account](https://app.posthog.com/signup).\n\nDeploy the example using [Vercel](https://vercel.com?utm_source=github\u0026utm_medium=readme\u0026utm_campaign=next-example-leggetter):\n\n[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/leggetter/with-posthog\u0026project-name=with-google-analytics\u0026repository-name=with-posthog)\n\nRemember to setup your `NEXT_PUBLIC_POSTHOG_TOKEN` [environment variable](https://vercel.com/docs/environment-variables) in Vercel.\n\n## How to use\n\nExecute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example::\n\n```bash\nnpx create-next-app --example https://github.com/leggetter/with-posthog\n# or\nyarn create next-app --example https://github.com/leggetter/with-posthog\n```\n\n### Setup PostHog\n\n[Sign up for a PostHog Cloud account](https://app.posthog.com/signup)\n\nOnce you have your account, create a copy of the `.env.local` configuration file from the example `.env.local.example` file:\n\n```\ncp .env.local.example .env.local\n```\n\nUpdate the `NEXT_PUBLIC_POSTHOG_TOKEN` variable in the new `.env.local` file with your PostHog token.\n\n### Deploy to Vercel\n\nDeploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github\u0026utm_medium=readme\u0026utm_campaign=next-example-leggetter) ([Documentation](https://nextjs.org/docs/deployment)).\n\nCreate and set an environment variable for `NEXT_PUBLIC_POSTHOG_TOKEN` using the following command and when prompted enter your PostHog token and select `a` for all environments:\n\n```\nvercel env add secret NEXT_PUBLIC_POSTHOG_TOKEN\n```\n\nDeploy:\n\n```\nvercel\n```\n\n## Running Locally\n\nRun the development server:\n\n```bash\nnpm run dev\n# or\nyarn dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) with your browser to see the result.\n\nYou can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.\n\n## Learn More\n\n### PostHog\n\nDemonstates using [PostHog](https://posthog.com) for:\n\n- [Page Views](https://posthog.com/docs/integrations/js-integration#one-page-apps-and-page-views)\n- [Custom Events/Capture via JS Web](https://posthog.com/docs/integrations/js-integration#sending-events)\n- [Setting identity via JS Web](https://posthog.com/docs/integrations/js-integration#identifying-users)\n- [Custom Events/Capture via Node.js](https://posthog.com/docs/integrations/node-integration#capture)\n\n\n**PostHog events dashboard**\n![PostHog events dashboard](_readme-assets/posthog-events-dashboard.png)\n\n**PostHog toolbar**\n![PostHog toolbar](_readme-assets/posthog-toolbar.png)\n\n**PostHog Funnel**\n![PostHog Funnel](_readme-assets/posthog-funnel.png)\n\nTo learn more about PostHog, take a look at the following resources:\n\n- [PostHog documentation](https://posthog.com/docs)\n- [posthog-js integration](https://posthog.com/docs/integrations/js-integration)\n- [posthog-node integration](https://posthog.com/docs/integrations/node-integration)\n\n### Next.js\n\nThis is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).\n\nTo learn more about Next.js, take a look at the following resources:\n\n- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.\n- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.\n\nYou can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!\n\n## Deploy on Vercel\n\nThe easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template\u0026filter=next.js\u0026utm_source=github\u0026utm_campaign=next-example-leggetter) from the creators of Next.js.\n\nCheck out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleggetter%2Fwith-posthog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleggetter%2Fwith-posthog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleggetter%2Fwith-posthog/lists"}