Next.js lead capture popup form with target options
I have a Next.js app where I included the tracking script in order to set up a lead tracking popup form. In my targeting configuration, under Website URL > Hide Pop-up, I specified URLs that contain "/admin" and "/application". I expect to not see the popup show on those pages but I still do.
I was able to pin down the specific issue but don't know what the solution is. The tracking script is only loading on the initial visit. Next.js does not reload scripts when navigating around the site. I've already tried tracking page views manually following the tracking code API guide. The page views are tracking correctly but the popup lead form still shows.
It seems that the lead form popup portion of the script is only initializing on the initial page visit and not on every page as it would on a typical site.
The problem is probably being caused because of the fact that you use a PWA created by Next.js. The tracking script will not reload because of the fact that you do not reload the page when changing pages, as it is probably a Single Page Application right?
So somehow, you need to simulate the page changes and let the tracking script know. I found this post, and they mention the Set Page Path function, which seems different from the Track Page View docs. Does this help?
Learn more about HubSpot by following me on LinkedIn or YouTube
✅ Did my answer solve your issue? Help the community by marking it as the solution.