La fonction de suggestion automatique permet d'affiner rapidement votre recherche en suggérant des correspondances possibles au fur et à mesure de la frappe.
Is it possible to wait for trackPageView before redirecting to an external page?
Hi - We have a WP page that loads the Hubspot tracking script via the WP plugin.
But sometimes the page needs to instantly redirect to an external website based on some JS we execute after page load.
It seems the hubspot script almost never executes, and we miss the majority of pageviews tracked by hubspot. We're using the wordpress plugin and it adds *asynchronous* and *defer* to the hubspot script, which is probably causing the issue.
So we tried adding a bit of javascript to force a trackPageView *before* we do the redirect. It executes after the page finishes loading. See snippet below.
Any way we can guarantee the trackPageView makes it to hubspot before the redirect?
------------ window.onload = function() {
// some logic here/do-stuff
// logic decides to instantly redirect
var _hsq = window._hsq = window._hsq || []; // Track the page view for the new page _hsq.push(['setPath', '/blahblahblah']); _hsq.push(['trackPageView']);
Is it possible to wait for trackPageView before redirecting to an external page?
// Track the page view for the new page
var _hsq = window._hsq = window._hsq || []; _hsq.push(['setPath', '/etc']); _hsq.push(['trackPageView']); <---- WAIT for hubpot to get the data before doing anything else
I want to do this, but must be certain hubspot receives the data before the code continues. Pretty sure it does all its work asynchronously.