Skip to content

Instantly share code, notes, and snippets.

<script type="text/javascript">
jQuery(document).ready(function() {
var hints = {
"name": "John Doe",
"email": "you@youremail.com",
"phone_number": "555-555-5555",
"company": "Company Name"
};
var hideHint = function(field, text){
<style type="text/css">
.lp-pom-form-field .hint {
color:#999999 !important; /* Grey */
}
</style>
@GaryUnbounce
GaryUnbounce / UA_FormClick
Last active August 29, 2015 13:56
Tracking Form Submission Buttons Clicks with Universal Analytics
<script>
$( '.lp-pom-form .lp-pom-button' ).click(function() {
if (lp.jQuery('form').valid() == true) {
ga('send', 'event', 'form', 'button', 'submit');
}
});
</script>
@GaryUnbounce
GaryUnbounce / UA_ButtonClick
Created February 18, 2014 22:04
Tracking Click-Through Button Clicks with Universal Analytics
<script>
$( '#lp-pom-button-23' ).click( function(event) {
event.preventDefault();
var buttonLink = $(this).attr("href");
if (typeof ga != 'function') {
window.location = buttonLink;
}
@GaryUnbounce
GaryUnbounce / GA_ButtonClick
Created February 18, 2014 22:07
Tracking Button Click with Google Analytics (classic)
<script>
$( '#lp-pom-button-23' ).click( function(event) {
event.preventDefault();
var buttonLink = $(this).attr("href");
var callbackFunction = function(){
window.location = buttonLink;
}
@GaryUnbounce
GaryUnbounce / FancyBox
Created February 18, 2014 22:20
Add a lightbox style window (for privacy policy, rules, terms, etc)
<script>
$(document).ready(function() {
$('#lp-pom-text-22 a').fancybox({
type: 'iframe',
width: 840,
height: 480
});
});
</script>
@GaryUnbounce
GaryUnbounce / SmoothScroll
Created February 18, 2014 22:27
Add Smooth Scrolling Button Links
<script>
$(document).ready(function(){
$("[#lp-pom-button-21").click(function(event){
event.preventDefault();
$('html, body').animate({ scrollTop: $("#form").offset().top }, 1000);
});
});
</script>
@GaryUnbounce
GaryUnbounce / FancyBox_Images
Created February 18, 2014 22:29
Add a lightbox style window for image previews
<script type="text/javascript">
jQuery(function() {
jQuery(".lp-pom-image a[target='_self']").fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'fade',
'overlayOpacity' : 0.8,
'overlayColor' : '#000',
'hideOnContentClick' : true
});
});
@GaryUnbounce
GaryUnbounce / Focus_FirstField
Created February 18, 2014 22:31
Automatically focus the first field of a form
<script type="text/javascript">
jQuery(function() {
jQuery('form input:text:visible:first').focus();
});
</script>
@GaryUnbounce
GaryUnbounce / SmoothScroll_Anchor
Created February 18, 2014 22:40
Create smooth scrolling anchor links
<script>
$(document).ready(function(){
$(".scroll").click(function(event){
//prevent the default action for the click event
event.preventDefault();
//get the full url - like mysitecom/index.htm#home
var full_url = this.href;