Add Google Analytics data to Jotform with GA Connector’s Jotform integration.
Prerequisites
- Installed either GA Connector WordPress plugin or GA Connector script on your website
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<script data-cfasync="false" type="text/javascript" src="https://tracker.gaconnector.com/gaconnector.js"></script> <script> function setGaconnectorHiddenFields() { var gaFields = gaconnector.getCookieValues(); for (var fieldName in gaFields) { var selectors = 'form input[name="' + fieldName + '"], form input#' + fieldName + ', form input#field_' + fieldName + ', form input[name="' + fieldName.toLowerCase() + '"], form input#' + fieldName.toLowerCase() + ', form input#field_' + fieldName.toLowerCase() + ', input[value="gaconnector_' + fieldName + '"],'; selectors += 'form textarea[name="'+fieldName+'"], form textarea#'+fieldName+', form textarea#field_'+fieldName + ', form textarea[name="'+fieldName.toLowerCase()+'"], form textarea#'+fieldName.toLowerCase()+', form textarea#field_'+fieldName.toLowerCase()+', form textarea.'+fieldName+', form textarea[name="param['+fieldName+']"]'+", form textarea[id^='field_"+fieldName+"']"; var inputs = document.querySelectorAll(selectors); if (inputs === null) { continue; } else if (typeof inputs.length === 'undefined') { inputs.value = gaFields[fieldName]; } else { for (var i = 0; i < inputs.length; i++) { inputs[i].value = gaFields[fieldName]; } } } } gaconnector.setCallback(setGaconnectorHiddenFields); setInterval(setGaconnectorHiddenFields, 1000); </script> |
Setting up the GA Connector Fields on Jotform
Step 1
While editing your form on the Jotform form builder, Add a new field for each GA Connector field that you want to track. For a list of all fields that you can track, please check the table at the end of this article.
Step 2
For each field, edit their Property and set the Unique Name to the respective GA Connector field ID. E.g. If you are going to track Last Click Source, set the Unique Name to lc_source. You can check out the GA Connector fields and their respective ID on the table at the end of this article. Make sure to hide the fields that you’ve created too.
Embedding your Jotform
Step 1
When embedding your Jotform, replace the “src” from the code to “data-jf-url”
Your final embed code should look like below:
1 |
<script type="text/javascript" data-jf-url="--YOUR JOTFORM URL HERE---"></script> |
Step 2
Right after pasting your new embed code at your website. Put this additional code right after it:
1 |
<script>window.addEventListener("DOMContentLoaded",(event=>{let gaFields=null,ctr=0;function updateJotForms(){let jotForms=document.querySelectorAll("script[data-jf-url]");if(jotForms.length>0)for(var i=0;i<jotForms.length;i++){let src=jotForms[i].dataset.jfUrl;if(gaFields){let separator=src.includes("?")?"&":"?";gaFieldsParams=new URLSearchParams(gaFields).toString(),src=src+separator+gaFieldsParams}jotForms[i].setAttribute("src",src)}}var interval=setInterval((function(){!function(){try{if(gaFields=gaconnector.getCookieValues(),"function"!=typeof ga)return!!gaFields.lc_source;if("function"==typeof ga.getAll)return!!gaFields.lc_source&&ga.getAll()[0].get("clientId")}catch(err){console.log("GA Connector script not found")}}()?ctr>5&&(updateJotForms(),clearInterval(interval)):(updateJotForms(),clearInterval(interval)),ctr++}),100)}));</script> |
In case you have multiple Jotform forms on your page, you can just paste this code once, right after all your forms.
That’s it!
More than just UTM parameters
GA Connector adds UTM information, geolocation, referral information to your Freshworks leads.
See below for all the information that you can add to your leads to help you find out which of your marketing activities drive sales.
Label | Input ID | Label | Input ID |
---|---|---|---|
All Traffic Sources | all_traffic_sources | Last Click Campaign | lc_campaign |
Browser | browser | Last Click Channel | lc_channel |
City (from IP address) | city | Last Click Content | lc_content |
Country (from IP address) | country | Last Click Landing Page | lc_landing |
First Click Campaign | fc_campaign | Last Click Medium | lc_medium |
First Click Channel | fc_channel | Last Click Referrer | lc_referrer |
First Click Content | fc_content | Last Click Source | lc_source |
First Click Landing Page | fc_landing | Last Click Term | lc_term |
First Click Medium | fc_medium | Last Click Timestamp | lc_timestamp |
First Click Referrer | fc_referrer | Longitude | longitude |
First Click Source | fc_source | Latitude | latitude |
First Click Term | fc_term | Number of Website Visits | page_visits |
First Click Timestamp | fc_timestamp | Operating System | OS |
Google Analytics CID | GA_Client_ID | Device | device |
Google Analytics Measurement ID | GA_Measurement_ID | Region | region |
Google Analytics Session ID | GA_Session_ID | Pages Visited | pages_visited_list |
Google Click Identifier | gclid | Time Spent on Website | time_passed |
IP Address | ip_address | Time Zone | time_zone |