Last active
January 19, 2016 21:03
-
-
Save raujohn/813a05cc5f9f29fa4d75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function ssCallBack( resp ) { | |
// Check if this visitor exists in SharpSpring as a contact | |
if ( typeof resp.contact != 'undefined' ) { | |
// Contact exists | |
// Get industry | |
if ( resp.contact['IndustrySelect'] ) { | |
var industry = resp.contact['IndustrySelect']; | |
} | |
// Check if contact has an opportunity | |
if ( resp.contact['Has an Opportunity'] ) { | |
// Opportunity exists, check if they are in Free Trial in pipeline | |
$.ajax( 'getOppStage.php?leadID=' + resp.contact['SharpSpring ID'], { | |
success: function( data ) { | |
if ( data == 1 ) { | |
// They haven an opportunity and it is in the Free trial stage | |
console.log( 'TRIAL' ); | |
// Show the Trial User CTA for their Industry | |
$( '#cta-trial-' + industry ).show(); | |
} else { | |
// They have an opportunity but it is NOT in the Free trial stage | |
$( '#lead-message .industry-label' ).html( industry ); | |
$( '#lead-message' ).show(); | |
// Show the Lead CTA for their Industry | |
$( '#cta-lead-' + industry ).show(); | |
} | |
}, | |
error: function( ) { | |
// Something went wrong so just classify them as a LEAD | |
$( '#lead-message .industry-label' ).html( industry ); | |
$( '#lead-message' ).show(); | |
// Show the Lead CTA for their Industry | |
$( '#cta-lead-' + industry ).show(); | |
} | |
}); | |
} else { | |
// No opportunity exists, this is a LEAD | |
$( '#lead-message .industry-label' ).html( industry ); | |
$( '#lead-message' ).show(); | |
// Show the Lead CTA for their Industry | |
$( '#cta-lead-' + industry ).show(); | |
} | |
} else { | |
// No contact record exists, this is an ANONYMOUS VISITOR | |
$( '#anonymous-visitor-message' ).show(); | |
// Show the Anonymous Visitor CTA | |
$( '#cta-anonymous-visitor' ).show(); | |
} | |
} | |
</script> | |
<script type="text/javascript"> | |
var _ss = _ss || []; | |
_ss.push(['_setDomain', 'https://koi-********.sharpspring.com/net']); | |
_ss.push(['_setAccount', 'KOI-********']); | |
_ss.push(['_trackPageView']); | |
_ss.push(['_setResponseCallback', ssCallBack ]); // Trigger the callback function above when SharpSpring loads | |
(function() { | |
var ss = document.createElement('script'); | |
ss.type = 'text/javascript'; | |
ss.async = true; | |
ss.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'koi-********.sharpspring.com/client/ss.js?ver=1.1.1'; | |
var scr = document.getElementsByTagName('script')[0]; | |
scr.parentNode.insertBefore(ss, scr); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment