CMS Development

iarambula
Member

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.

0 Upvotes
4 Replies 4
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Next.js lead capture popup form with target options

@iarambula ,

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.


dennisedson
HubSpot Product Team
HubSpot Product Team

Next.js lead capture popup form with target options

@iarambula 

Have you had a chance to check out these docs?

Here is the overview page.  You can scroll down to the SPA section for more info

0 Upvotes
iarambula
Member

Next.js lead capture popup form with target options

@dennisedson Yes. As far as I can tell, those docs are pretty much identical to the ones I linked in my original post.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Next.js lead capture popup form with target options

Oh dear god, dennis.  Read the entire post before responding 😅

I believe I deserve this:

 

Dear @Teun , @miljkovicmisa ,

please save me from myself here!

0 Upvotes