Embeddable Widgets

Supported templates

  • The Newsletter Referral
  • The Milestone Referral
  • The Altruistic Referral
  • Refer a Friend
  • The Shopify Referral

The Javascript snippet

The first thing you have to do in order to use the Javascript API is to add a code snippet before the closing tag in your page. This is going to capture the referrals in your website and also it will make some Viral Loops methods available to your application.

Get the snippet at the Installation step of your Campaign Wizard.

Depending on the template that your campaign is built with, the snippet may be diferrent. In general, it looks like this:

<script>!function(){var a=window.VL=window.VL||{};return a.instances=a.instances||{},a.invoked?void(window.console&&console.error&&console.error("VL snippet loaded twice.")):(a.invoked=!0,void(a.load=function(b,c,d){var e={};e.publicToken=b,e.config=c||{};var f=document.createElement("script");f.type="text/javascript",f.id="vrlps-js",f.defer=!0,f.src="https://app.viral-loops.com/client/vl/vl.min.js";var g=document.getElementsByTagName("script")[0];return g.parentNode.insertBefore(f,g),f.onload=function(){a.setup(e),a.instances[b]=e},e.identify=e.identify||function(a,b){e.afterLoad={identify:{userData:a,cb:b}}},e.pendingEvents=[],e.track=e.track||function(a,b){e.pendingEvents.push({event:a,cb:b})},e.pendingHooks=[],e.addHook=e.addHook||function(a,b){e.pendingHooks.push({name:a,cb:b})},e.$=e.$||function(a){e.pendingHooks.push({name:"ready",cb:a})},e}))}();var campaign=VL.load("{{campaignId}}",{autoLoadWidgets:!0});</script>

What’s Next

Embed your first widget!