I’m building a landing page where new website visitors who arrive on our page via a custom url shall be identified so that their data such as name and e-mail address can be accessed.
The process is as follows:
Email address is used to identify user via _hsq.push, followed by a custom event and window.location to forward user to the final landingpage (website.com/landingpage)
All user data can be accessed via http data on the final landingpage
Here’s the code which is executed on the blank landingpage:
var _hsq = window._hsq = window._hsq || [];
The problem I’m facing is that if the window.location function forwards the user, data has not succesfully been pushed to Hubspot. When I’m making use of a 2 second delay (as you can see being commented out) however it works.
I understand that the _hsq.push function runs asynchronously. Is there a way to trigger the window.location forward once the data has been pushed to hubspot successfully and can be used on the final landing page?
Just to make sure that we’re on the same page, you’re pushing the contact info to HubSpot using the identify method, and then pulling the info from HubSpot using your PHP script on the final landing page? You could try passing the contact info to the final landing page via some other method (e.g. query parameters) so that you could customize the page content and call the identify method on the final page.
You’re correct that the tracking code methods are run asynchronously; there isn’t currently any way to force these methods to be synchronous, or otherwise delay the page forwarding until the methods are called. Would it be possible for you to call the tracking code methods on the final landing page, instead of using a blank intermediary page?
thanks for your reply. Yes it would be possible to call those methods on the final landing page. However we’re using php script to access the identified visitors information (name, email address, company url) on the final landing page to customize the page. Therefore the call tracking code methods have to be called on the intermediary page already. As for now I created a 3 seconds js delay on the intermediary page which works fine in most cases but of course isn’t convenient for the user. Would be great if we could figure out a workaround.