The saga continues
It turns out that…
{{ widget.cta_area }}
…generates something that looks like this…
hbspt.cta.load(158015, ‘ccd39b7c-ae18-4c4e-98ee-547069bfbc5b’);
…according to documentation here; Accounts Dashboard | HubSpot
The hbspt.cta.load function ends up calling, amongst other things, this…
displayCta
…which can be overridden with one’s own function like this…
window.hbspt.cta.displayCta = function(pAccount, pCtaId, pMystery, a) {
…etc…
}
…the above function refers to ‘this’ which will not work, so another variable has to be set first that points to what should be ‘this’ and that variable used within the function, so…
var that = window.hbspt.cta;
window.hbspt.cta.displayCta = function(pAccount, pCtaId, pMystery, a) {
…
s.type = “text/javascript”, s.async = !0, s.src=that.getCtaLoaderScriptSrc(account, ctaid, noideahowtochangethis, a), that.ctaLoaded = !1, that.onCTAReady = addParams, that.utils.log(pCtaId + " loading with src: " + s.src), (document.getElementsByTagName(“head”)[0] || document.getElementsByTagName(“body”)[0]).appendChild(s);
…
}
…within which one can intercept the onCTAReady event. In the above this was done with an addParams function in the hope that the CTA URL could be updated with extra parameters.
The above line (s.type…) generates a JavaScript tag that’s appended to the DOM. When this parameter driven JavaScript is returned it contains the ultimate CTA destination in an <a> tag in the cta_dest_link attribute. It was hoped by updating this attribute that parameters could be added to the destination URL. Alas no, seems that this attribute is for reference only and changing it has no effect.
It now appears that Hack v2.0 is required, meaning that the original CTA is activated via an AJAX GET (so that Hubspot’s internal tracking knows that it was), the results of the call then discarded (i.e. the built in redirection is not allowed to happen). Instead the updated URL is constructed (including the required parameters) and redirected to independently without using Hubspot at all. This will of course look like ‘clickjacking’.
Is there really no way to transmit custom parameters to a CTA destination URL?