Ads

sb_1
Member

Ads Offline Conversion Tracking: Get GCLID & FB Lead ID

Hi all, 

 

when thinking about sending offline conversion data back to Google Ads and Facebook Ads from Hubspot (so MQL / SQL etc. values via events - great feature by the way!), I came accross this post: 

https://knowledge.hubspot.com/ads/create-and-sync-crm-lifecycle-events-with-your-google-ads-or-faceb...

 

In the bottom part it says that GCLID and FB Lead ID are send back to the ad tools. This, of course, implies that they are necessary within Hubspot, too. 

 

Does someone know how Hubspot captures them? Is it done automatically or do I need to implement it manually in the form tracking (hidden form fields)?

 

Maybe someone can help?

7 Replies 7
Danielle1
Participant

Ads Offline Conversion Tracking: Get GCLID & FB Lead ID

I figured out how to store and capture the GCLID using the code below in Tagmanager for contacts in Hubspot. However, I still need code to do the same thing for the MSCLKID (Microsoft Click ID for Microsoft Ads). If you know how to fix this problem, please paste the code for tagmanager in the reply.

 

If you need help with storing the GCLID, paste the code below into tagmanager using all pages as the trigger.

 

<script>


function getParam(p) {
var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}

function getExpiryRecord(value) {
var expiryPeriod = 90 * 24 * 60 * 60 * 1000; // 90 day expiry in milliseconds

var expiryDate = new Date().getTime() + expiryPeriod;
return {
value: value,
expiryDate: expiryDate
};
}

function addGclid() {
var gclidParam = getParam('gclid');
var gclidFormFields = ['gclid_field', 'foobar']; // all possible gclid form field ids here
var gclidRecord = null;
var currGclidFormField;

var gclsrcParam = getParam('gclsrc');
var isGclsrcValid = !gclsrcParam || gclsrcParam.indexOf('aw') !== -1;

gclidFormFields.forEach(function (field) {
if (document.getElementById(field)) {
currGclidFormField = document.getElementById(field);
}
});

if (gclidParam && isGclsrcValid) {
gclidRecord = getExpiryRecord(gclidParam);
localStorage.setItem('gclid', JSON.stringify(gclidRecord));
}

var gclid = gclidRecord || JSON.parse(localStorage.getItem('gclid'));
var isGclidValid = gclid && new Date().getTime() < gclid.expiryDate;

if (currGclidFormField && isGclidValid) {
currGclidFormField.value = gclid.value;
}
}

window.addEventListener('load', addGclid);

</script>

 

You will also have to create a property in Hubspot called gclid and change it to hidden on your forms. 

MadLeads
Member

Ads Offline Conversion Tracking: Get GCLID & FB Lead ID

@jfrade what would be the best way to take advantage of hubspot lifecycle stage changes in Facebook if I'm not runing a Lead Ads campaign but rather a standard form submit conversion on a landing page. I'm asking because I noticed we don't sync any lifecycle stage events back with facebook, only with google, and it appears this is due to not running any lead ads campaigns (poor quaility for us). Would it be best to make an audience based around an MQL segmented contact list for example?

0 Upvotes
jfrade
HubSpot Employee
HubSpot Employee

Ads Offline Conversion Tracking: Get GCLID & FB Lead ID

Hey @sb_1 ! Glad you're liking the offline conversions feature. For Google you will need to make sure auto tagging is turned off, which ensures that Google will automatically add the GCLID to the URL as well as having HS Ads auto tracking turned off. This way when contacts click and convert on your ad that will get stored on the contact record under the "google click id" property.

 

For Facebook, the offline conversions feature only works with lead ad conversions, so if you are running lead ads any time a new lead comes through it will automatically have a lead id on the contact record.

 

- Jason

ASavoi
Participant

Ads Offline Conversion Tracking: Get GCLID & FB Lead ID

Hi Jason, which is the Contact property where the Facebook Lead ID is stored?

Thanks so much

0 Upvotes
MCPDX
Participant

Ads Offline Conversion Tracking: Get GCLID & FB Lead ID

Was this a typo? Pretty sure auto-tagging needs to be turned ON for Google to append GCLIDs to the URL?

"For Google you will need to make sure auto tagging is turned off, which ensures that Google will automatically add the GCLID to the URL"

0 Upvotes
sb_1
Member

Ads Offline Conversion Tracking: Get GCLID & FB Lead ID

Hi @jfrade,

 

thanks very much - really helps und solves our issue! There would be one additional question 😉 Is it planned to also enable sending offline conversions to LinkedIn lead gen ads?

 

Best,

sb

0 Upvotes
jfrade
HubSpot Employee
HubSpot Employee

Ads Offline Conversion Tracking: Get GCLID & FB Lead ID

@sb_1 not at this time, we only have offline conversions for Facebook and Google.

0 Upvotes