-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Marketo Form Extension files #39
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Add Marketo Form to any Page | ||
|
||
Fill out the editable fields, corresponding to the Marketo code and the position of the form relative to an element of your choosing on the page. | ||
|
||
Here are the fields: | ||
 | ||
|
||
This is how the fields correspond to the Marketo code: | ||
 | ||
|
||
Click Save. To view, click Preview Mode! | ||
|
||
Please note that because of how Marketo loads the form, this is only visible in Preview Mode - so you won't be able to see it in the Visual editor. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"plugin_type": "widget", | ||
"name": "Add Marketo Form", | ||
"edit_page_url": "https://www.atticandbutton.us/", | ||
"form_schema": [ | ||
{ | ||
"default_value": "https://app-123.marketo.com/js/forms2/js/forms2.min.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the format of this url always have the same pattern? like "https://app-.marketo.com/js/forms2/js/forms2.min.js" Right now the extension code is kind of generically inserting a script from some location and if the user accidentally puts in the wrong URL, they could be loading the wrong or potentially even malicious script on their page. One way around this might be to only allow users to configure the so that we always guarantee that this extension adds a script from a marketo domain. However, this assumes marketo won't change the format of their URL. Or we could rely on users to ensure they paste in the right script here as you are doing here. I think this is fine either way, but would appreciate your thoughts. |
||
"field_type": "text", | ||
"name": "external_script", | ||
"label": "external script", | ||
"options": null | ||
}, | ||
{ | ||
"default_value": "mktoForm_1234", | ||
"field_type": "text", | ||
"name": "form_id", | ||
"label": "form ID", | ||
"options": null | ||
}, | ||
{ | ||
"default_value": "//app-123.marketo.com", | ||
"field_type": "text", | ||
"name": "load_form_1", | ||
"label": "First parameter of Marketo loadForm Function", | ||
"options": null | ||
}, | ||
{ | ||
"default_value": "ABC-123-456", | ||
"field_type": "text", | ||
"name": "load_form_2", | ||
"label": "Second parameter of Marketo loadForm Function", | ||
"options": null | ||
}, | ||
{ | ||
"default_value": 1234, | ||
"field_type": "number", | ||
"name": "load_form_3", | ||
"label": "Third parameter of Marketo loadForm Function", | ||
"options": null | ||
}, | ||
{ | ||
"default_value": "body", | ||
"field_type": "selector", | ||
"name": "element", | ||
"label": "Add form relative to this element", | ||
"options": null | ||
}, | ||
{ | ||
"default_value": "beforebegin", | ||
"field_type": "dropdown", | ||
"name": "position", | ||
"label": "Relative position to element", | ||
"options": { | ||
"choices": [ | ||
{ | ||
"value": "beforebegin", | ||
"label": "Before the element itself" | ||
}, | ||
{ | ||
"value": "afterbegin", | ||
"label": "Just inside the element, before its first child." | ||
}, | ||
{ | ||
"value": "beforeend", | ||
"label": "Just inside the element, after its last child." | ||
}, | ||
{ | ||
"value": "afterend", | ||
"label": "After the element itself." | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"description": "", | ||
"options": { | ||
"apply_js": "var utils = optimizely.get('utils');\n\n/**\nStep 1: Inject Marketo Script\nStep 2: Insert form HTML\nStep 3: Load the form using Marketo's functions.\n**/\n\n//Step 1\nvar tag = document.createElement(\"script\");\ntag.setAttribute('type','text/javascript');\ntag.setAttribute('src',extension.external_script);\ndocument.head.appendChild(tag);\n\n//Step 2\nutils.waitForElement(extension.element)\n .then(function(elem) {\n // Prepend the extension html to the element\n elem.insertAdjacentHTML(extension.position, extension.$html);\n \n }).then(function(){\n//Step 3\n utils.waitUntil(function(){\n return typeof MktoForms2 == 'object';\n }).then(function(elem) {\n window.MktoForms2.loadForm(extension.load_form_1, extension.load_form_2, extension.load_form_3);\n });\n});\n\n", | ||
"html": "<div id=\"opty-extension-container\">\n <div id=\"optimizely-extension-{{ extension.$instance }}\" class=\"test-extension-\">\n \t<form id=\"{{ extension.form_id }}\"></form>\n\t</div>\n</div>", | ||
"css": "#opty-extension-container{\n\tpadding-bottom: 150px;\n}", | ||
"undo_js": "var extensionElement = document.getElementById('optimizely-extension-' + extension.$instance);\nif (extensionElement) {\n extensionElement.parentElement.removeChild(extensionElement);\n}\n" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great screenshots!