Skip to content

Instantly share code, notes, and snippets.

View johnnyopao's full-sized avatar
✌️

Johnny Opao johnnyopao

✌️
View GitHub Profile
@johnnyopao
johnnyopao / youtube-vb-min.md
Last active December 15, 2022 11:43
Youtube Video Background for Unbounce pages - Minified
@johnnyopao
johnnyopao / scrollandstick.html
Last active December 15, 2022 11:43
Scroll and Stick Fixed Header
<script>
//Scroll and Stick Fixed header v1.0
//Replace ID below with your box ID
var boxToFix = '#lp-pom-box-587';
var boxParent = $(boxToFix).parent();
var boxClone = $(boxToFix).clone().attr('id', boxToFix + '-bg');
var topPositionOfBox = $(boxToFix).position().top;
@johnnyopao
johnnyopao / scrollandstickmin.html
Last active December 15, 2022 11:43
Scroll and Stick Fixed Header Min
<script>
//Scroll and Stick Fixed header v1.0
//Replace ID below with your box ID
var boxToFix = '#lp-pom-box-587';
function showOrHideHeader(){var o=$(window).scrollTop();o>topPositionOfBox?($(boxToFix).css({position:"fixed",top:"0px"}),$(boxClone).css({position:"fixed",top:"0px"})):($(boxToFix).css({position:"absolute",top:topPositionOfBox}),$(boxClone).css({position:"absolute",top:boxTop}))}var boxParent=$(boxToFix).parent(),boxClone=$(boxToFix).clone().attr("id",boxToFix+"-bg"),topPositionOfBox=$(boxToFix).position().top,boxHeight=$(boxToFix).css("height"),boxTop=$(boxToFix).css("top"),boxBorderWidthTop=$(boxToFix).css("border-top-width"),boxBorderWidthBottom=$(boxToFix).css("border-bottom-width"),boxBorderWidthLeft=$(boxToFix).css("border-left-width"),boxBorderWidthRight=$(boxToFix).css("border-right-width"),boxBorderStyleTop=$(boxToFix).css("border-top-style"),boxBorderStyleBottom=$(boxToFix).css("border-bottom-style"),boxBorderStyleLeft=$(boxToFix).css("border-left-style"),boxBorderStyl
@johnnyopao
johnnyopao / GAclientidUnbounce.md
Last active December 15, 2022 11:43
GA Cross domain: Carry Analytics ClientID across domains

GA Cross domain tracking: Carry over Analytics ClientID across domains

Google Analytics

This code is used to track users in GA across two completely different root domains (A.com to B.com). Insert the code below into your Unbounce landing page.

<script>
  $('.lp-pom-button, .lp-pom-text a, .lp-pom-image a').click(function(event) {
 var parentClass = $(this).parent().attr('class');
@johnnyopao
johnnyopao / image-text-URL-params.html
Created February 19, 2015 21:18
Carry over URL parameters to text and image links on Unbounce
<script>
$(function() {
$('.lp-pom-image a, .lp-pom-text a').not('a[href^=#]').each( function() {
this.href = this.href + window.location.search;
});
});
</script>
@johnnyopao
johnnyopao / addDigitValidation.md
Created April 1, 2015 21:29
Add numbers/digits only validation to a Unbounce form field
<script>
window.module.lp.form.data.validationRules['field_name'].digits = true;
</script>

Replace 'field_name' with the ID of your form field you want to add this validation to.

@johnnyopao
johnnyopao / unbounceFancybox.html
Created April 16, 2015 21:32
Updated Fancybox script
<script>
$(function() {
$('#lp-pom-button-22').fancybox({
type: 'iframe',
width: 840,
height: 480,
centerOnScroll: true,
onStart: function() {
$('#fancybox-content').css({overflow: 'scroll', '-webkit-overflow-scrolling': 'touch'});
}
@johnnyopao
johnnyopao / currencyValidation.html
Last active December 15, 2022 11:42
This validates a field for currency for dollar and cents. Ex: 42.50
<script>
lp.jQuery(function($) {
var ruleID = 'currency';
var field = 'money_field';
var message = 'Please enter a valid currency';
var rules = module.lp.form.data.validationRules[field];
@johnnyopao
johnnyopao / urlparamanchor.html
Last active December 15, 2022 11:42
Pass URL parameters to Unbounce links containing Anchors
<script>
$(function() {
$('.lp-pom-image a, .lp-pom-text a, .lp-pom-button').not('a[href^=#]').each( function() {
var currentURL = this.href;
var hashIndex = currentURL.indexOf("#");
var hasAnchor = hashIndex > -1;
var hashString = "";
var baseURL = this.href;
@johnnyopao
johnnyopao / dropdownformconfirmationurl.md
Last active December 15, 2022 11:42
Change form destination URL by dropdown selection on Unbounce
  1. Be sure to first change your forms confirmation to 'Goto another webpage' and set a default fallback URL

  2. Drop this script into your javascript box. Set the placement to 'before body end tag'

<script>

$("#gender").live('change', function() {
 
 switch ($(this).val()) {