Add Google Analytics data to Pardot with GA Connector’s Pardot integration.
- Install our Salesforce package.
- Go to Pardot – Forms.
- Select a form you want to add to GA Connector.
- Click “Edit form”.
- Click “Fields” add all fields from our Salesforce package.
- Open “Look and Feel” and select “Below Form”.
- Click the “Code” symbol ()in the editor. This will allow to paste raw HTML code there.
- Paste this code in the editor:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
<script> var gaconnectorFieldsMap = { "all_traffic_sources": "All_Traffic_Sources", "browser": "Browser", "fc_campaign": "First_Click_Campaign", "fc_channel": "First_Click_Channel", "fc_content": "First_Click_Content", "fc_landing": "First_Click_Landing_Page", "fc_medium": "First_Click_Medium", "fc_referrer": "First_Click_Referrer", "fc_source": "First_Click_Source", "fc_term": "First_Click_Term", "GA_Client_ID": "GA_Client_ID", "gclid": "Google_Click_Identifier", "ip_address": "IP_Address", "region": "Region", "lc_campaign": "Last_Click_Campaign", "lc_channel": "Last_Click_Channel", "lc_content": "Last_Click_Content", "lc_landing": "Last_Click_Landing_Page", "lc_medium": "Last_Click_Medium", "lc_referrer": "Last_Click_Referrer", "lc_source": "Last_Click_Source", "lc_term": "Last_Click_Term", "latitude": "Latitude", "longitude": "Longitude", "page_visits": "Number_of_Website_Visits", "OS": "Operating_System", "pages_visited_list": "Pages_Visited", "time_passed": "Time_Spent_On_Website", "time_zone": "Time_Zone", "device": "Device" }; function receiveGaconnectorData(event) { var gaFields = event.data; var limit = 255; if (typeof gaFields['lc_source'] !== 'undefined') { for (var gaconnectorName in gaconnectorFieldsMap) { if(typeof gaFields[gaconnectorName] !== 'undefined') { if (gaFields[gaconnectorName].length > limit) { gaFields[gaconnectorName] = gaFields[gaconnectorName].substr(0, limit); } } var pardotName = gaconnectorFieldsMap[gaconnectorName]; var input = document.querySelector("p." + pardotName + " input[type=hidden]"); if (input !== null) { input.value = gaFields[gaconnectorName]; } } } } window.addEventListener("message", receiveGaconnectorData, false); </script> |
This code allows Pardot iframes to receive GA Connector data from the parent window.
Finally, paste this code on your website (on every page):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<script data-cfasync="false" type="text/javascript" src="https://tracker.gaconnector.com/gaconnector.js"></script> <script> function setGaconnectorHiddenFields() { var gaFields = gaconnector.getCookieValues(); setInterval(function() { var pardotForm = document.querySelectorAll("iframe.pardotform"); if (pardotForm !== null) { for (var i = 0; i < pardotForm.length; i++) { pardotForm[i].contentWindow.postMessage(gaFields, "*"); } } }, 1000); } gaconnector.setCallback(setGaconnectorHiddenFields); </script> |
Finally, add class=”pardotform” to all your Pardot iframes so they look like this:
<iframe class=”pardotform” style=”border: 0;” src=”http://go.pardot.com/…..” width=”350″ height=”510″ frameborder=”0″></iframe>
<iframe class=”pardotform” style=”border: 0;” src=”http://go.pardot.com/…..” width=”350″ height=”510″ frameborder=”0″></iframe>
More than just UTM parameters
GA Connector adds UTM information, geolocation, referral information to your Pardot leads.