Skip to content

Instantly share code, notes, and snippets.

@johanmendezb
Last active October 27, 2016 14:42
Show Gist options
  • Save johanmendezb/e8da56953893c078583009d5b83f469e to your computer and use it in GitHub Desktop.
Save johanmendezb/e8da56953893c078583009d5b83f469e to your computer and use it in GitHub Desktop.
//this script onlo works with jquery1.11.1
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
// all the fields must be filled with it's respective id
var buttonId = "//field id";
var nameId = "//field id";
var emailId = "//field id";
var phoneId = "//field id";
// catches the landing url
var landing = window.ub.page.name + " ["+window.ub.page.variantId+"]";
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
var lan;
// catches the landing cookie where the user started browsing
$(document).ready(function(){
lan = getCookie("landing");
if(lan != ""){
$("#landing_inicial").val(lan);
}
else{
$("#landing_inicial").val(landing);
document.cookie = "landing="+landing;
lan = landing;
}
});
$(buttonId).on('touchstart click', function(e){
$("#idname").val($(nameId).val());
$("#idemail").val($(emailId).val());
$("#idphone").val($(phoneId).val());
$("#tag_initial").val("inicial "+lan);
if(lan != landing){
$("#tag_conversion").val("conv "+landing);
}
if($("#idname").val() != "" && $("#idemail").val() != "" && $("#idphone").val() != "")
{
$("#agile-form").submit();
}
});
</script>
<form class="form-view" id="agile-form" action="https://mesfix.agilecrm.com/formsubmit" method="POST" style="display:none">
<div style="display: none; height: 0px; width: 0px;">
<input type="hidden" id="_agile_form_name" name="_agile_form_name" value="campaign">
<input type="hidden" id="_agile_domain" name="_agile_domain" value="mesfix">
<input type="hidden" id="_agile_api" name="_agile_api" value="srdjlitkq1dk230nqrqv2hg396">
<input type="hidden" id="_agile_redirect_url" name="_agile_redirect_url" value="https://www.mesfix.com/thankyou">
<input type="hidden" id="tag_initial" name="tags" value="">
<input type="hidden" id="tag_conversion" name="tags" value="">
<input type="hidden" name="tags" value="lead_emp">
<input type="hidden" id="_agile_form_id" name="_agile_form_id" value="">
<input type="hidden" id="_agile_form_id_tags" name="Vendedor" value="on">
<input type="hidden" name="Status" value="Lead">
<input id="idname" name="first_name" type="hidden" placeholder="Nombre y apellido" class="form-start" validate="true" maxlength="45" required="">
<input id="idemail" name="email" type="hidden" placeholder="Correo electrónico " validate="true" maxlength="45" required="">
<input id="idphone" name="phone" type="hidden" placeholder="Teléfono" validate="true" maxlength="45" required="">
<input id="idname" name="first_name" type="hidden" placeholder="Nombre y apellido" class="form-start" validate="true" maxlength="45" required="">
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment