How to create new Contacts via Tracking API, but limit to certain pages?

Hi all,

I have some questions about the tracking API and I would greatly appreciate your help.

I’m not a developer, but I’d like to understand this as well as I can, so I know exactly what to ask our dev team.

We have the Hubspot tracking code installed on our website example.com. Here, visitors can:

- submit a form to request a demo - this creates a new Contact or links to existing Contact

- click “Start for Free” - this brings them to our web app on app.example.com where they can create a new user account (via Google OAuth, Microsoft Oauth, or Email + Password)

We are using a tool called Hightouch (Connected App in Hubspot) to create a new Contact for this new User account, or link to an existing one.

However, when Hightouch creates a new Contact, it doesn’t know/contain the utk/cookie information. Therefor, when it creates a new Contact, Hubspot is not able to link (past and future) example.com website visits to the Contact.

If I understand it correctly, the Tracking Code API could help here, with the identify function and trackPageView call. (We have Marketing Professional so no Custom Behavioral Events.)

Questions:

  1. Is the Tracking Code API indeed the way to go for us, using page view events?
  2. Can we just add the Tracking Code to our web app and it will work fine? Or do we need to do anything additionally for our cross/sub domain tracking?
  3. Can we limit the tracking code only to certain pages? (For example only trigger a page view on the Home page in the app, instead of each page)
  4. Can we limit the number of page view events somehow? (For example 1 per 10 minutes, instead of flushing the Contact’s timeline with page views)
  5. Any other advice/best practice on how to link across a marketing website and web app?

Any input/advice is greatly appreciated, thanks!!

Michiel

Hi @Mvs,

Are you able to add the HubSpot tracking script on app.example.com?

If so, once a user registers, you could use the form submission API and pass along the hutk cookie.
Using the tracking code API, you can indeed identify the contact.

If app.example.com is a single-page application, you can use the track page view function to trigger a pageview in HubSpot. Once the tracking script is loaded, this will be triggered by default. However, if your app.example.com is indeed a single-page application, you would then need to trigger each following pageview event yourself. That means you can also limit the amount of pageviews, as you have full control when that event is triggered.
It is advised to set up cross-domain linking as well.

Hope this helps!

Hi Teun, thanks for your response. I hope you’re having a nice weekend!

Next week, we will try adding the Hubspot tracking code to our web app via GTM.

1. The form submission API links to a legacy document. Would you still recommend that instead of using the Tracking Code API? And will the form submission API also work when people Sign up/Log in via Google instead of by filling out their email + password?

2. Our web app is not a single page application, but, using GTM, I think we can still choose on which pages we want to trigger the page_view events. Is that correct?

3. Ah okay, I wasn’t sure if we were supposed to set up domain linking, as app.example.com is a sub domain of example.com. But now I understand we should :slightly_smiling_face:

4. We’re on Hubspot Pro so we don’t have Custom Behavioral Events. That means we can ONLY send page_view events to Hubspot, right? (And e.g. no sign_up or log_in events)

5. Final question. When we add the Hubspot tracking code also to our app, we want to prevent showing a cookie banner IN our app (users accept tracking in our terms of service when they create their accounts). How can we keep the cookie banner on example.com but prevent it from showing after sign up/log in on app.example.com?

Kind regards,

Michiel

Hi @Teun

We have now installed GTM on our dev environment (dev.app.example.com).

I’ve added the default Hubspot tracking as Custom HTML:
<!-- Start of HubSpot Embed Code -->
<script type=“text/javascript” id=“hs-script-loader” async defer src=“//js-eu1.hs-scripts.com/26640364.js”></script>
<!-- End of HubSpot Embed Code -->

Could you explain me how can we now add the identify funtion and trackPageView events?

As part of the same Hubspot Tracking Code Custom HTML Tag?

Kind regards,

Michiel