# ViralSweep

<figure><img src="https://3790748257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT43PzcNjyZtWby9yrGd3%2Fuploads%2FxNSH984Nonus4t10Z50E%2F4a49ca4f-2ad6-4c81-8c2f-cfd54b84d811.png?alt=media&#x26;token=c8ec1b49-5007-4973-b099-c7e1f826738a" alt=""><figcaption></figcaption></figure>

#### ViralSweep is the ultimate platform for creating and managing captivating contests, sweepstakes, and promotions. <a href="#viralsweep-is-the-ultimate-platform-for-creating-and-managing-captivating-contests-sweepstakes-and-p" id="viralsweep-is-the-ultimate-platform-for-creating-and-managing-captivating-contests-sweepstakes-and-p"></a>

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](https://konnektive.atlassian.net/wiki/spaces/CC/pages/1859551673/Checkout+Champ+Account+Settings#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>`

Be the first to add a reaction
