Viralsweep
ViralSweep is the ultimate platform for creating and managing captivating contests, sweepstakes, and promotions.
To add Viralsweep to your funnel(s), edit the Thank You page(s) and place the following code in the <body>
of the page.
Global Scripts can be used to place the code on multiple Thank You pages within a funnel, or a domain.
The last 2 lines are unique to your ViralSweep account.
Replace "
#####_######
" with the value for your account.Replace the "
src
" value with the URL generated on your ViralSweep account.
Viralsweep requires the use of a Shopify plugin. Orders placed against the campaign must be sending the orders back to Shopify.
<script type="text/javascript">
// Set orderQueryUrl string value type variable with production URL
const orderQueryUrl = "https://live-api.checkoutchamp.com/providersApi/V1/ClubMembership/OrderQueryByOrderId";
// Set ccClientOrderQueryIterations numeric value type variable with number of order query iteraton needed to fetch required order details, currently set to 5
const ccClientOrderQueryIterations = 5;
var ccClientOrderCheckInterval, ccClientOrderQueryCallCount = 1;
// function to set order data details on form rendered by viral sweep, function accepts an object type parameter contains order details
function ccSetClientViralSweepDetails(orderData) {
try {
if (orderData && window.vs_prefill_field) {
orderData.emailAddress && vs_prefill_field("email", orderData.emailAddress);
orderData.phoneNumber && vs_prefill_field("phone", orderData.phoneNumber);
vs_prefill_field("order_id", orderData.vendorOrderId || orderData.orderId);
vs_prefill_field("auto_submit", "true")
}
} catch(err) {err;}
}
async function ccClientOrderQuery(payload, orderData) {
try {
if (payload && orderData) {
if (ccClientOrderQueryCallCount > ccClientOrderQueryIterations) {
ccSetClientViralSweepDetails(orderData);
return;
}
ccClientOrderQueryCallCount++;
const data = await httpMethod(orderQueryUrl, payload);
if (data && data.result === "SUCCESS" && data.message && data.message.vendorOrderId) {
ccSetClientViralSweepDetails(data.message);
return;
}
setTimeout(function() { ccClientOrderQuery(payload, orderData); }, 3000);
}
} catch (err) {
setTimeout(function() { ccClientOrderQuery(payload, orderData); }, 3000);
}
}
function ccClientInitializeOrderSearchInterval() {
if (window.location.path !== "blank") {
ccClientOrderCheckInterval = setInterval( function() {
try {
const orderDataString = sessionStorage.getItem("orderData");
const orderData = (orderDataString && JSON.parse(orderDataString)) || {};
if (httpMethod && orderData.orderId) {
clearInterval(ccClientOrderCheckInterval);
if (sessionStorage.getItem("ccShopifyProducts")) {
const payload = JSON.stringify({ "orderId": orderData.orderId, "finalizeTransaction": 1 });
ccClientOrderQuery(payload, orderData);
} else {
ccSetClientViralSweepDetails(orderData);
}
}
} catch (err) {err;}
}, 3000);
}
}
function vs_widget_load_callback() {
ccClientInitializeOrderSearchInterval();
}
</script>
<!-- Script to render viral sweep form, update script src with script URL generated from viralsweep -->
<div id="vsscript_#####_######" data-secondsdelay=""></div>
<script async type="text/javascript" src="https://app.viralsweep.com/vsa-widget-******-*****.js?sid=#####_######"></script>