I have a CTA on a page that is a landing page containing the usual utm_.* parameters plus some other ones. I need to get the parameters from the URL, for example...
...such that when the CTA on the page (in this case a button) is clicked, the parameters are then associated with the link that is redirected to as a result of the CTA, but in a slightly different format...
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) {
...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?
If we can not track our campains pointing to the HS landings page then redirecting to our main site, we will be forced to stop using hubspot landing and/or cta and replace with another solution (looking for it now)
If this functionaliy is not available out of the box, I was thinking of adding some JavaScript to the page (hack) that would look for CTA links (this sort of thing; https://cta-service-cms2.hubspot.com/ctas...) and update them with the necessary extra parameters, but am not sure what form such parameters should take to ensure they survive the 30x redirects.