Skip to content

Instantly share code, notes, and snippets.

View brianaohern's full-sized avatar
🐶

Briana brianaohern

🐶
View GitHub Profile
// REPLACE THIS WITH THE CAMPAIGN'S ID
var campaignId = 'XXXXXX';
document.addEventListener('tp.Main.EventListener.Ready', function () {
var event = new CustomEvent('tp.Custom.Submit', {
bubbles: true,
cancelable: true,
detail: {
widgetId: campaignId,
@brianaohern
brianaohern / om-custom-js.js
Created August 20, 2018 20:56
Custom JavaScript Example
<script>
// Your custom JavaScript.
// If you're adding jQuery, please make sure your website already has a jQuery library loaded, or you will need to add it yourself.
</script>
@brianaohern
brianaohern / om-js-wordpress.php
Created July 27, 2018 17:28
WordPress JavaScript Example
<?php wp_footer(); ?>
// Your JavaScript goes below
<script type="text/javascript">
// This example calls om.Campaign.init runs once the campaign is initialized
document.addEventListener('om.Campaign.init', function(event) {
// This event is passed the Campaign object
console.log(event.detail.Campaign);
@brianaohern
brianaohern / om-load-jquery.html
Created July 23, 2018 17:29
OM Load jQuery False
<script>
var om_load_jquery = false;
</script>
@brianaohern
brianaohern / om-iframe-conversion-example.html
Last active August 11, 2019 22:02
iFrame Conversion Example
<a id="iframeCover" class="om-trigger-conversion"></a>
<div id="formInstructions">Double Click Below to Get Started</div>
<iframe src="https://docs.google.com/forms/d/e/1FAIpQLScS9FplM0-5VouPWZareiRJjtIZLO_g5jcDW1eQ52k2W_2SyQ/viewform?embedded=true" width="500" height="520" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>
<script type="text/javascript">
var myIframeCover = document.querySelector('html div#om-{{id}} #iframeCover');
myIframeCover.addEventListener("click", function() {
myIframeCover.style.display = 'none';
});
</script>
@brianaohern
brianaohern / om-iframe-conversion.html
Last active February 7, 2021 23:08
iFrame Conversion Script
<script type="text/javascript">
var myIframeCover = document.querySelector('html div#om-{{id}} #iframeCover');
myIframeCover.addEventListener("click", function() {
myIframeCover.style.display = 'none';
});
</script>
@brianaohern
brianaohern / om-custom-required.js
Created July 17, 2018 14:26
Custom Required Script
<script type="text/javascript">
var form = document.querySelector('html div#om-YOUR-OPTIN-SLUG .NAMESPACE-FieldsElement--content');
var errorAlert = document.querySelector("html div#om-YOUR-OPTIN-SLUG .NAMESPACE-FieldsElement--content #errorAlert");
var formSubmitButton = document.querySelector("html div#om-YOUR-OPTIN-SLUG .NAMESPACE-FieldsElement--content input.om-trigger-conversion"); /* This variable is a flag to know if a user has attempted to submit at least once. */
var attemptToSubmitAtLeastOnceFlag = false; /* This code hides the error field. */
function fieldsCheck() {
var lookForInvalidInputs = document.querySelectorAll('html div#om-YOUR-OPTIN-SLUG .NAMESPACE-FieldsElement--content :invalid'); /* Scan Form for All Inputs that currently have a :placeholder-shown pseudo-class */
var lookForInputsShowingPlaceholders = document.querySelectorAll('html div#om-YOUR-OPTIN-SLUG .NAMESPACE-FieldsElement--content :placeholder-shown'); /* If there are no "invalid" states OR P
@brianaohern
brianaohern / om-Html-append-after-example.js
Created July 12, 2018 17:32
om.Html.append.after Example
document.addEventListener('om.Html.append.after', function(event) {
console.log('The ' + event.detail.Campaign.id + '-' + event.detail.Campaign.type + ' main container is now attached to the outer DOM.');
} );
@brianaohern
brianaohern / om-Action-close-example.js
Created July 12, 2018 17:30
om.Action.close Example
// Function SaveToDisk forces file download instead of viewing in browser
function SaveToDisk(fileURL, fileName) {
// for non-IE
if (!window.ActiveXObject) {
var save = document.createElement('a');
save.href = fileURL;
save.target = '_blank';
save.download = fileName || 'unknown';
var event = document.createEvent('Event');
@brianaohern
brianaohern / om-Action-redirect-example.js
Created July 12, 2018 17:20
om.Action.redirect Example
document.addEventListener('om.Action.redirect', function(event) {
console.log(“Redirect in progress...”);
} );