Skip to content

Instantly share code, notes, and snippets.

@RobertCam
Created December 27, 2016 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertCam/ce75e8fcfa1dcd7157c16c79d3719ed9 to your computer and use it in GitHub Desktop.
Save RobertCam/ce75e8fcfa1dcd7157c16c79d3719ed9 to your computer and use it in GitHub Desktop.
Trigger a lightbox based on certain URL parameters
<script>
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}
var button = $('#lp-pom-button-309'); // Add ID of lightbox button
var email = getURLParameter('email'); // Look for this parameter to trigger the lightbox
var first_name = getURLParameter('first_name'); // Look for this parameter to trigger the lightbox
if (email || first_name) {
setTimeout(function () {
$(button)[0].click(); // add the ID of your lightbox button
}, 100);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment