-
-
Save lukebussey/c1aeb4113e90c519d522 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function () { | |
| var getCookieForMarketo = function (name) { | |
| if (arguments.length === 0 && typeof opts !== 'string') { | |
| return; | |
| } | |
| var match = document.cookie.match('(?:^|; )' + name + '=([^;]+)'); | |
| if (match) { | |
| return match[1]; | |
| } else { | |
| return 'NULL'; | |
| } | |
| }; | |
| if (typeof MktoForms2 === 'object') { | |
| MktoForms2.whenReady(function (form) { | |
| // Add hidden fields | |
| form.addHiddenFields({ | |
| UTMCampaign: getCookieForMarketo('utm_campaign'), | |
| UTMSource: getCookieForMarketo('utm_source'), | |
| UTMMedium: getCookieForMarketo('utm_medium'), | |
| UTMTerm: getCookieForMarketo('utm_term'), | |
| UTMContent: getCookieForMarketo('utm_content') | |
| }); | |
| // Send an event to GA then redirect to destination URL after 200ms | |
| form.onSuccess(function (form, url) { | |
| ga('send', 'event', 'Landing Pages', 'Form Filled', 'Name of Landing Page', { | |
| hitCallback: function () { | |
| window.location.href = url; | |
| } | |
| }); | |
| return false; | |
| }); | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment