{"id":119,"date":"2017-02-08T21:30:00","date_gmt":"2017-02-08T21:30:00","guid":{"rendered":"http:\/\/support.gaconnector.com\/?p=119"},"modified":"2025-09-22T12:49:49","modified_gmt":"2025-09-22T12:49:49","slug":"add-ga-connector-tracking-to-pardot-iframe-forms","status":"publish","type":"post","link":"https:\/\/gaconnector.com\/docs\/add-ga-connector-tracking-to-pardot-iframe-forms\/","title":{"rendered":"Add GA Connector tracking to Pardot iFrame forms"},"content":{"rendered":"<p data-pm-slice=\"1 1 [&quot;blockquote&quot;,{}]\">The instructions below apply to\u00a0<strong>Cookie-Based integration<\/strong>.<\/p>\n<p data-pm-slice=\"1 1 [&quot;blockquote&quot;,{}]\">If you are using\u00a0<strong>API-Based integration<\/strong>, simply add the GA Connector script to both your main website and inside the Pardot form iframe. No additional steps are required.<\/p>\n<p data-pm-slice=\"1 1 [&quot;blockquote&quot;,{}]\">Not sure which instructions to follow? Start here:\u00a0<strong><a class=\"ProsemirrorEditor-link\" href=\"https:\/\/gaconnector.com\/docs\/how-to-check-which-ga-connector-integration-type-youre-using\/\">How to Check Which GA Connector Integration Type You\u2019re Using<\/a>.<\/strong><\/p>\n<h4><em>Add Google Analytics data to Pardot with GA Connector\u2019s Pardot integration.<\/em><\/h4>\n<ol>\n<li>Install <a href=\"https:\/\/gaconnector.com\/docs\/documentation-for-our-basic-integration-salesforce-package\/\">our Salesforce package<\/a>.<\/li>\n<li>Go to\u00a0<a href=\"https:\/\/pi.pardot.com\/form\/forms\">Pardot &#8211; Forms<\/a>.<\/li>\n<li>Select a form you want to add to GA Connector.<\/li>\n<li>Click &#8220;Edit form&#8221;.<\/li>\n<li>Click &#8220;Fields&#8221;\u00a0add\u00a0all fields from\u00a0<a href=\"https:\/\/gaconnector.com\/docs\/documentation-for-our-basic-integration-salesforce-package\/\">our Salesforce package<\/a>.<\/li>\n<li>Open &#8220;Look and Feel&#8221; and select &#8220;Below Form&#8221;.<\/li>\n<li>Click the &#8220;Code&#8221; symbol (<img decoding=\"async\" class=\"alignnone\" src=\"https:\/\/i.gyazo.com\/e40d3710d0dea6cfda11e4e3285e0d2b.png\" alt=\"Code symbol\" width=\"20\" height=\"21\" \/>)in the editor. This will allow\u00a0to paste\u00a0raw HTML code there.<\/li>\n<li>Paste this\u00a0code in\u00a0the editor:<\/li>\n<\/ol>\n<pre class=\"lang:default decode:true \">&lt;script&gt;\r\n\tvar gaconnectorFieldsMap = {\r\n        \"all_traffic_sources\": \"All_Traffic_Sources\",\r\n        \"browser\": \"Browser\",\r\n        \"fc_campaign\": \"First_Click_Campaign\",\r\n        \"fc_channel\": \"First_Click_Channel\",\r\n        \"fc_content\": \"First_Click_Content\",\r\n        \"fc_landing\": \"First_Click_Landing_Page\",\r\n        \"fc_medium\": \"First_Click_Medium\",\r\n        \"fc_referrer\": \"First_Click_Referrer\",\r\n        \"fc_source\": \"First_Click_Source\",\r\n        \"fc_term\": \"First_Click_Term\",\r\n        \"GA_Client_ID\": \"GA_Client_ID\",\r\n        \"gclid\": \"Google_Click_Identifier\",\r\n        \"ip_address\": \"IP_Address\",\r\n        \"region\": \"Region\",\r\n        \"lc_campaign\": \"Last_Click_Campaign\",\r\n        \"lc_channel\": \"Last_Click_Channel\",\r\n        \"lc_content\": \"Last_Click_Content\",\r\n        \"lc_landing\": \"Last_Click_Landing_Page\",\r\n        \"lc_medium\": \"Last_Click_Medium\",\r\n        \"lc_referrer\": \"Last_Click_Referrer\",\r\n        \"lc_source\": \"Last_Click_Source\",\r\n        \"lc_term\": \"Last_Click_Term\",\r\n        \"latitude\": \"Latitude\",\r\n        \"longitude\": \"Longitude\",\r\n        \"page_visits\": \"Number_of_Website_Visits\",\r\n        \"OS\": \"Operating_System\",\r\n        \"pages_visited_list\": \"Pages_Visited\",\r\n        \"time_passed\": \"Time_Spent_On_Website\",\r\n        \"time_zone\": \"Time_Zone\",\r\n        \"device\": \"Device\"\r\n    };\r\n\r\n    function receiveGaconnectorData(event) {\r\n        var gaFields = event.data;\r\n        var limit = 255;\r\n        if (typeof gaFields['lc_source'] !== 'undefined') {\r\n            for (var gaconnectorName in gaconnectorFieldsMap) {\r\n                if(typeof gaFields[gaconnectorName] !== 'undefined') {\r\n                    if (gaFields[gaconnectorName].length &gt; limit) {\r\n                        gaFields[gaconnectorName] = gaFields[gaconnectorName].substr(0, limit);\r\n                    }\r\n                }\r\n                var pardotName = gaconnectorFieldsMap[gaconnectorName];\r\n                var input = document.querySelector(\"p.\" + pardotName + \" input[type=hidden]\");\r\n                if (input !== null) {\r\n                    input.value = gaFields[gaconnectorName];\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    window.addEventListener(\"message\", receiveGaconnectorData, false);\r\n&lt;\/script&gt;<\/pre>\n<p>This code allows Pardot iframes to receive GA Connector data from the parent window.<\/p>\n<p>Finally, paste this code on your website (on every page):<\/p>\n<pre class=\"lang:default decode:true \">&lt;script data-cfasync=\"false\" type=\"text\/javascript\" src=\"https:\/\/tracker.gaconnector.com\/gaconnector.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\nfunction setGaconnectorHiddenFields() {\r\n    var gaFields = gaconnector.getCookieValues();\r\n    setInterval(function() {\r\n        var pardotForm = document.querySelectorAll(\"iframe.pardotform\");\r\n        if (pardotForm !== null) {\r\n            for (var i = 0; i &lt; pardotForm.length; i++) {\r\n                pardotForm[i].contentWindow.postMessage(gaFields, \"*\");\r\n            }\r\n        }\r\n\r\n    }, 1000);\r\n}\r\n\r\ngaconnector.setCallback(setGaconnectorHiddenFields);\r\n&lt;\/script&gt;<\/pre>\n<div><\/div>\n<div>Finally, add class=&#8221;pardotform&#8221; to all your Pardot iframes so they look like this:<br \/>\n&lt;iframe<span style=\"text-decoration: underline;\"><strong> class=&#8221;pardotform&#8221;<\/strong><\/span> style=&#8221;border: 0;&#8221; src=&#8221;http:\/\/go.pardot.com\/&#8230;..&#8221; width=&#8221;350&#8243; height=&#8221;510&#8243; frameborder=&#8221;0&#8243;&gt;&lt;\/iframe&gt;<\/div>\n<div><\/div>\n<div>\n<h2>More than just UTM parameters<\/h2>\n<p>GA Connector adds UTM information, geolocation, referral information to your Pardot leads.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The instructions below apply to\u00a0Cookie-Based integration. If you are using\u00a0API-Based integration, simply add the GA Connector script to both your main website and inside the Pardot form iframe. No additional steps are required. Not sure which instructions to follow? Start here:\u00a0How to Check Which GA Connector Integration Type You\u2019re Using. Add Google Analytics data to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,16],"tags":[],"_links":{"self":[{"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/posts\/119"}],"collection":[{"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":17,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":3736,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/posts\/119\/revisions\/3736"}],"wp:attachment":[{"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gaconnector.com\/docs\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}