I use a QR code to point users to a landing page (which is on a postal letter sent to a Hubspot contact). I am able to customise the landing page based on variables in the URL using HubL HTTP request variables {{% request.query_dict %}}. Is there any way that I can add something to the URL to feed back into Hubspot so I know the user has visited the site and add it to their activity record?
const urlParams = new URLSearchParams(window.location.search); const email = urlParams.get('email');
console.log('Email from URL:', email);
if (email) { // Wait for HubSpot's form API to be ready var checkHubSpot = setInterval(function() { if (window.hbspt) { clearInterval(checkHubSpot); console.log('HubSpot loaded');
// Find the form after a short delay setTimeout(() => { const forms = document.querySelectorAll('form.hs-form'); console.log('Forms found:', forms.length);
forms.forEach(form => { const emailField = form.querySelector('input[name="email"]'); if (emailField) { emailField.value = email; console.log('Email field populated');
const urlParams = new URLSearchParams(window.location.search); const email = urlParams.get('email');
console.log('Email from URL:', email);
if (email) { // Wait for HubSpot's form API to be ready var checkHubSpot = setInterval(function() { if (window.hbspt) { clearInterval(checkHubSpot); console.log('HubSpot loaded');
// Find the form after a short delay setTimeout(() => { const forms = document.querySelectorAll('form.hs-form'); console.log('Forms found:', forms.length);
forms.forEach(form => { const emailField = form.querySelector('input[name="email"]'); if (emailField) { emailField.value = email; console.log('Email field populated');
Thank you for the prompt response, unfortunately they will not have an HS cookie installed as we are cold apporoaching them via a postal letter, hence the question, There is information about them in the URL (via the QR code) and this is used to personalise the landing page - so I was hoping these could be fed back into Hubspot in some way?
You did say the contact existed already in your HubSpot database - right? If so, then they may have a cookie from a previous conversion.
Depending on how determined you are, it would be possible to include a contact reference (ID perhaps) coded into your personalized URL and use that to associate the web session with a contact record.
@SteveHTM they are unlikely to have visited our site before and, therefore, to have a cookie but this.... "Depending on how determined you are, it would be possible to include a contact reference (ID perhaps) coded into your personalized URL and use that to associate the web session with a contact record." is exactly what I would like to do if you know how - I can definitely add the ID to the URL but need to know how to process it on the landing page... If you can help me with that I will be very grateful! 🙏🏼
They may be a number of ways to add such functionality, but I'd start exploring along the lines of:
- understanding how you could trigger a workflow based on a specific URL visit that included a contact ID. This may require some creativity 🙂
- Using that contact ID in the workflow (possibily needing a custom code workflow step) to write details of the visit to the contact record.
It would be nice to think you could do all this in HubL customization code on the landing page (as a side effect of crm_object() perhaps), but writing anything to the database is tricky in my experience.
@pbeville - if the browser used to visit the site has a HS cookie installed, or sthe site visit later turns into a form conversion, then HubSpot automatically tracks the visit session on the Contact record. You can also use such visits to trigger workflows etc. or change score.