# Installing Hubspot Tracking Code in a Next.js v14 App

**URL:** <https://community.hubspot.com/t/installing-hubspot-tracking-code-in-a-next-js-v14-app/96647>\
**Category:** CMS Development\
**Tags:** html\
**Created:** [December 21, 2023, 9:55pm UTC](https://community.hubspot.com/t/installing-hubspot-tracking-code-in-a-next-js-v14-app/96647 "2023-12-21T21:55:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatOfCle](https://avatars.discourse-cdn.com/v4/letter/p/8baadc/32.png) [@PatOfCle](https://community.hubspot.com/u/PatOfCle)\
**Post date:** [December 21, 2023, 9:55pm UTC](https://community.hubspot.com/t/installing-hubspot-tracking-code-in-a-next-js-v14-app/96647/1 "2023-12-21T21:55:47Z")

</div>

Hi all. Next.js is becoming a widely used web framework, and I am using it for my company website. Unfortunately, I cannot figure out how to get the tracking code working.

Here is a similar post that a “solution” was provided for: [https://community.hubspot.com/t5/APIs-Integrations/Next-js-tracking-code-installation/td-p/753441](https://community.hubspot.com/t5/APIs-Integrations/Next-js-tracking-code-installation/td-p/753441). I tried this solution from [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) (although Next v14 uses the App Router instead of Pages Router), and it did not solve the problem.

If anyone knows how to get this working for Next.js, please let me know. My company has a few other action items contingent on us getting tracking up and running.

Thank you!

---

<div class="post-metadata">

**Author:** ![tverdokhlib1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tverdokhlib1/32/58857_2.png) [@tverdokhlib1](https://community.hubspot.com/u/tverdokhlib1)\
**Post date:** [December 22, 2023, 7:29pm UTC](https://community.hubspot.com/t/installing-hubspot-tracking-code-in-a-next-js-v14-app/96647/2 "2023-12-22T19:29:05Z")

</div>

@PatOfCle Did you try to embed the HubSpot tracking code into the Head of next.js based on this documentation [Components: Head | Next.js](https://nextjs.org/docs/pages/api-reference/components/head) ?

---

<div class="post-metadata">

**Author:** ![PatOfCle](https://avatars.discourse-cdn.com/v4/letter/p/8baadc/32.png) [@PatOfCle](https://community.hubspot.com/u/PatOfCle)\
**Post date:** [December 23, 2023, 10:19pm UTC](https://community.hubspot.com/t/installing-hubspot-tracking-code-in-a-next-js-v14-app/96647/3 "2023-12-23T22:19:46Z")

</div>

Hi @tverdokhlib1 , yes I did try that. Firstly, that is from the Pages Router under Next.js. Secondly, putting it in the Head component really isn’t any different than putting the script in the top level layout.js file in the App Router.

I believe that there has to be something done on a per-page basis for Next.js SSR, or at the “top level” there has to be some information passed to Hubspot about what page the user is on.

But to answer your question, no the link did not solve my problem. Thank you though.

---

<div class="post-metadata">

**Author:** ![waldothedevelop](https://avatars.discourse-cdn.com/v4/letter/w/d9b06d/32.png) [@waldothedevelop](https://community.hubspot.com/u/waldothedevelop)\
**Post date:** [August 29, 2024, 4:47am UTC](https://community.hubspot.com/t/installing-hubspot-tracking-code-in-a-next-js-v14-app/96647/4 "2024-08-29T04:47:19Z")

</div>

Let me know if you find a way of doing it. @PatOfCle

---

<div class="post-metadata">

**Author:** ![lpansarini](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@lpansarini](https://community.hubspot.com/u/lpansarini)\
**Post date:** [September 17, 2024, 2:39pm UTC](https://community.hubspot.com/t/installing-hubspot-tracking-code-in-a-next-js-v14-app/96647/5 "2024-09-17T14:39:59Z")

</div>

I’m facing the same issue and there is solve on it?
