Tiggles ツ
3/12/2018 - 4:44 PM

Email URL Capture

This will snag the email that had been appended to the URL, and will fill this into the first email field for easy user completion.

example here: https://www.christcommunityhealth.org/subscribe/?e=no@email.com

function getParamValue(paramName) {
	        var url = window.location.search.substring(1); //get rid of "?" in querystring
	        var qArray = url.split('&'); //get key-value pairs
	        for (var i = 0; i < qArray.length; i++) 
	        {
	            var pArr = qArray[i].split('='); //split key and value
	            if (pArr[0] == paramName) 
	                return pArr[1]; //return value
	        }
	    }
	    var emailAddress = getParamValue('e');
	    console.log(emailAddress);
	    if (document.getElementById("email_address_0")) {
	      document.getElementById("email_address_0").value = emailAddress;
} 
	
	
	
// 	i had to wrap this in a window.setTimeout(function() {}, 2000); to get it to work on the example page