Usage
This function runs automatically, so it is not called manually. Is this incorrect?
Additional Notes
Important: This function requires the “Attribution Tracking” Nebula Option to be enabled in order to use it! Be sure that the use of this cookie fits within your privacy policy and other regulations.
To send this data to third-party CRMs, make a hidden text input field with the class “attribution” in your CRM form. It will automatically get filled if that data exists.
To use it in a “local” form, you can do it the same way as above, but if you are using Contact Form 7 with Nebula no action is required unless you want that information to be sent in the email message. This attribution data will otherwise be stored automatically in Nebula’s Contact Form 7 Submissions admin page.
Source File
Located in /assets/js/modules/measure.js on line 1757.
No Hooks
This function does not have any filters or actions available. Request one?nebula.attributionTracking = function(){ if ( nebula.site.options.attribution_tracking ){ //If the Nebula Option is enabled if ( nebula.isDoNotTrack() ){ return false; } //Check if relevant query parameters exist in the URL //This overwrites anytime there is a UTM tag, so it would be considered "last-non-organic" attribution const queryParams = new URLSearchParams(window.location.search); if ( queryParams.has('utm_source') ){ //Check for the only required UTM tag (since .has() cannot do partial matches) //Loop through the query string to capture just the UTM parameters let utmParameters = {}; //Prep an object to fill for ( const [key, value] of queryParams.entries() ){ if ( key.includes('utm_') ){ //If this key is a UTM parameter utmParameters[key] = value; } } nebula.createCookie('attribution', JSON.stringify(utmParameters)); //Store the UTM parameters in a cookie } else if ( !nebula.readCookie('attribution') ){ //If no UTMs and the cookie does not already exist, check for other notable tracking parameters let trackingParameters = {}; //Prep an object to fill //Loop through notable tracking parameters to store in the attribution cookie let notableQueryParameters = { google_ads_click: 'gclid', //Google Ads Click ID google_ads_source: 'gclsrc', //Google Ads Click Source google_ads_gbraid: 'gbraid', google_ads_wbraid: 'wbraid', doubleclick: 'dclid', //DoubleClick Click ID (typically offline tracking) facebook: 'fbclid', linkedin: 'li_', hubspot: 'hsa_', mailchimp: 'mc_eid', vero: 'vero_id', marketo: 'mkt_tok' }; jQuery.each(notableQueryParameters, function(platform, parameter){ if ( queryParams.has(parameter) ){ //If this parameter exists trackingParameters[parameter] = queryParams.get(parameter); //Store it in the object } }); if ( trackingParameters ){ //If we ended up with a non-empty object nebula.createCookie('attribution', JSON.stringify(trackingParameters)); //Store the other notable parameters in a cookie } } //Now check if the cookie exists if ( nebula.readCookie('attribution') && jQuery('input.attribution').length ){ //If our attribution cookie exists and we have an input to use jQuery('input.attribution').val(nebula.readCookie('attribution')); //Fill the designated form field(s) } } };
Override
To override or disable this JavaScript function, simply redeclare it with the exact same function name. Remember: Some functionality is conditionally loaded via dynamic imports, so if your function is not overriding properly, try listening for a DOM event (described below).
For non-module import functions:
nebula.attributionTracking = function(){ //Write your own code here, leave it blank, or return false. }
For dynamically imported module function overrides:
jQuery(window).on('load', function(){ nebula.attributionTracking = function(){ //Write your own code here, leave it blank, or return false. } });
Custom Nebula DOM events do also exist, so you could also try the following if the Window Load listener does not work:
jQuery(document).on('nebula_module_loaded', function(module){ //Note that the module variable is also available to know which module specifically was imported if ( typeof nebula.attributionTracking === 'function' ){ nebula.attributionTracking = function(){ //Write your own code here, leave it blank, or return false. } } });