Skip to content

Instantly share code, notes, and snippets.

View johnnyopao's full-sized avatar
✌️

Johnny Opao johnnyopao

✌️
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / youtube-vb-min.md
Last active December 15, 2022 11:43
Youtube Video Background for Unbounce pages - Minified
@johnnyopao
johnnyopao / youtube-vb.js
Last active December 15, 2022 11:43
Youtube Video Background for Unbounce pages
<script>
// Youtube Video Background for Unbounce. V1.3.5
// lpVideoBG('#SectionID', 'YoutubeVideoID', width, height, muted);
// Use '#lp-pom-root' for a full page video background
lpVideoBG('#lp-pom-block-9', 'vLUNWYt3q1w', 560, 315, 0);
function lpVideoBG(pageSectionID, youtubeVideoCode, videoWidth, videoHeight, muted) {
var onMobile = navigator.userAgent.match(/(Android|iPod|iPhone|iPad|iemobile|blackberry)/);
@johnnyopao
johnnyopao / StateValAbb.js
Last active December 15, 2022 11:43
Assign state abbreviations to your Unbounce 'State' dropdown field
<script>
$(function() {
// The dropdown's ID
var id = '#state';
var values = {
'Alabama': 'AL',
'Alaska': 'AK',
@johnnyopao
johnnyopao / text-image-GA-events.js
Last active December 15, 2022 11:39
Triggering GA events for image/text links on Unbounce
<script>
// Replace #lp-pom-image-13 with the ID of your image or text box. Be sure to retain the trailing 'a'
$( '#lp-pom-image-13 a' ).click( function(event) {
event.preventDefault();
var buttonLink = $(this).attr("href");
if (typeof ga != 'function') {
window.location = buttonLink;
@johnnyopao
johnnyopao / left-align-root.css
Created October 14, 2014 23:50
Align Page content Left on Unbounce Pages
<style>
#lp-pom-root {
float:left;
}
</style>