Skip to content

Instantly share code, notes, and snippets.

@erikzrekz
Last active June 6, 2025 15:15
Show Gist options
  • Save erikzrekz/4debe8d8387b2af1de40bc98f6dbd2f0 to your computer and use it in GitHub Desktop.
Save erikzrekz/4debe8d8387b2af1de40bc98f6dbd2f0 to your computer and use it in GitHub Desktop.
Chiliipiper Debug

Inside <head> Tag

<META NAME="ROBOTS" CONTENT="NOINDEX">
<link rel="canonical" href="https://marketerhire.com/hire/schedule">

<style>
    .preloader {
        display: inline;
        z-index: 2000;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-color: white;
        transition: opacity .65s ease;
    }

    .loading-bar {
        width: 12%;
        height: 5px;
        background-color: #6affdd;
        transition: width 8000ms cubic-bezier(.25, 0, 0, 1);
    }

</style>

<script>
    // Determine whether this is the production or staging domain
    console.log("SQL CP Scheduler onStart  => " + Math.floor(Date.now()))


    let site_domain = window.location.hostname;
    if (urlParams.get("staging_typeform") == "true" && !site_domain.includes("marketerhire.com")) {
        internalRedirect("https://marketerhire.com/hire/schedule");
    }

</script>

<script>
    document.addEventListener("DOMContentLoaded", function () {
        requestAnimationFrame(function () {
            document.getElementById("loadingBar").style.width = "100%";
        });
    });
</script>


<script src="https://js.chilipiper.com/marketing.js" type="text/javascript"></script>
<script>
    if (urlParams.get("typeform_source") == 'typeform_mas') {
        console.log("typeform_mas " + "inbound-mas_router");
        ChiliPiper.getQuery("marketerhire", "inbound_mas_router", { queryVariable: "email" });
    }
    else {
      ChiliPiper.getQuery("marketerhire", "inbound_sql_router", { queryVariable: "email",onSuccess:function(){
  	window.location.replace(`https://marketerhire.com/ty-schedule-sql?email=${urlParams.get("email")}&firstname=${urlParams.get("firstname")}&lastname=${urlParams.get("lastname")}`)
  } });
      console.log("SQL route");
    		}
</script>

<script>qp('track', 'Purchase');</script>

Before </body> tag

<script>
    window.onload = function () {
        console.log("SQL CP Scheduler onload  => " + Math.floor(Date.now()))
        document.getElementById("loadingIndicator").style.opacity = "0";




        (async () => {
            try {
                var new_lead_score = parseInt(urlParams.get("score"));
                var new_lead_score_tier = urlParams.get("tier");
                const route = urlParams.get("route");
                const email = urlParams.get("email");
                const typeform_source = urlParams.get("typeform_source");
                var v1ValuesToUpdate = { properties: [] };




                if (route == "Natural_SQL") {
                    console.log("SQL CP Scheduler Pre-Clearbit call  => " + Math.floor(Date.now()))
/*
                    var funding = false;
                    var estimatedAnnualRevenue = null;
                    var clear_bit_response = await fetch(
                        "https://us-central1-dev-testing-1-347916.cloudfunctions.net/cors-proxy-clearbit?domain=" + email.substring(email.lastIndexOf("@") + 1),
                        {
                            method: 'GET',
                            headers: {
                                'Access-Control-Allow-Origin': '*',
                            },
                        }
                    );
                    const clear_json = await clear_bit_response.json()
                    estimatedAnnualRevenue = clear_json.metrics.estimatedAnnualRevenue;
                    console.log("clear_json().metrics.estimatedAnnualRevenue:" + estimatedAnnualRevenue);
                    console.log("SQL CP Scheduler POST-Clearbit call  => " + Math.floor(Date.now()))




                    //CALCULATE TIER VALUES
                    funding = estimatedAnnualRevenue ? true : false;
                    // Calculate New lead score
                    new_lead_score += funding ? 20 : 0;
                   
                    */
                    console.log("new_lead_score" + new_lead_score)
                   
                    //Assign Tier
                    if (new_lead_score > 60) {
                        new_lead_score_tier = "Tier 1"
                    }
                    else if (new_lead_score > 30) {
                        new_lead_score_tier = "Tier 2"
                    }
                    else {
                        new_lead_score_tier = "Tier 3"
                    }


                }
                //
                console.log("SQL CP Scheduler Pre-Hubspot call  => " + Math.floor(Date.now()))


                //update the propertiees
                v1ValuesToUpdate['properties'].push({ property: "lead_scoring_model_version", value: new_lead_score });
                v1ValuesToUpdate['properties'].push({ property: "new_lead_score_tier", value: new_lead_score_tier });
                v1ValuesToUpdate['properties'].push({ property: "new_route", value: route });
                v1ValuesToUpdate['properties'].push({ property: "typeform_source", value: typeform_source });


                console.log("SQL Tier values : " + JSON.stringify(v1ValuesToUpdate))


                var hubspot_response = fetch(
                    "https://us-central1-dev-testing-1-347916.cloudfunctions.net/cors-proxy-hubspot?email=" + urlParams.get("email"),
                    {
                        method: 'POST',
                        headers: {
                            'Access-Control-Allow-Origin': '*',
                        },
                        body: JSON.stringify(v1ValuesToUpdate)


                    }
                );


            } catch (err) {
                console.log("err" + err)
            }
            console.log("SQL CP Scheduler POST-Hubspot call  => " + Math.floor(Date.now()))


        })()




        setTimeout(function () {
            document.getElementById("loadingIndicator").style.display = "none";
        }, 450);
    }
</script>




<script>
    setCookie("rbsubevent", "true", 30);
    setCookie('rbsub', 'true', 30);


    analytics.ready(function () {
        //fbq('track', 'CompleteRegistration');
        //analytics.track("Hire Form Submitted", {email: urlParams.get("email")});
        //analytics.track("Lead Converted to SQL", {email: urlParams.get("email")});
    });
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment