Viral Loops integration not working

I am trying to set up Viral Loops. I added this code to Pro > Theme Options > JS:

!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("9P_4kZtSvzdW96meemvNcX8iMS4",{autoLoadWidgets:!0});`

And then put this in the page at http://emergencyadapters.io/referral-program/
<div data-vl-widget="embedForm"></div>

But not only is the page not displaying, somehow the site logo is showing as localhost:emergencyadapters.io and I’m not sure where to change that.

Here are the integration instructions from Viral Loops

Hi @quantazelle,

Thanks for writing in.

Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself.

If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

Thank you for your understanding.

This is something that works within normal Wordpress and not with Pro. So this is kind of under the scope of the theme.

Hi there,

I have checked your site and there is a Javascript error that is caused by some of the codes that you currently have in the Global JS. This could be the cause why the code you have added is not working.

Please try to fix the JS code first to avoid unexpected issues.

After that, you can try loading the Viral Loops JS code through the child theme.

You can do this by adding this code to the functions.php file of the child theme:

add_filter('wp_head', 'viral_loops_js');

function viral_loops_js() {
?>
<script>
    <!-- Add the custom JS code here -->
</script>	
<?php
}

Please check this link for some information on how to check for JS errors:

https://codex.wordpress.org/Using_Your_Browser_to_Diagnose_JavaScript_Errors

Hope this helps.

Well, I tried debugging the Javascript but couldn’t get it working. I went with the workaround in the last post and that totally worked! Thanks so much!

Glad that we could be of a help :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.