How to add Global Variable in an Embed (JS Code) because we don't use an Url. Thanks

How to add Global Variable in an Embed (JS Code) because we don't use an Url. Thanks

Hi there,

You can have a look at this article to understand the entire process of adding Global Variable in an Embed (JS Code): https://help.surveysparrow.com/tracking-logged-in-users-with-surveysparrow-widget

Feel free to reach out if you have any further questions or queries. We will be more than happy to help.

Have a great day ahead :slight_smile:

Hi!

I’m interested in this use case, but unfortunately the link is not working anymore. Where can I access this information?

Thanks!

Hey there!

You can access the information here.

Please check and let me know if this works! :slight_smile:

Thanks in advance!

Hey, I am also interested in this, since I have an exact use case, but above link is not working... So I would appreciate it if someone could share a way to embed global variable in with embed share.

Edit:
I found an article that explains how to use custom variables but with popup, and our case is inline embed...

HI @nemanjanasradin ,

Welcome to the community

Please find the sample code below.

<div id="ss_survey_widget"></div><script>(function(){var e="ss-widget",t="script",a=document,r=window;var s,n,c;r.SS_WIDGET_TOKEN="tt-bc151f2928";r.SS_ACCOUNT="jayeshurath2222222.surveysparrow.com";r.SS_SURVEY_NAME="test-unique";if(!a.getElementById(e)){var S=function(){S.update(arguments)};S.args=[];S.update=function(e){S.args.push(e)};r.SparrowLauncher=S;s=a.getElementsByTagName(t);c=s[s.length-1];n=a.createElement(t);n.type="text/javascript";n.async=!0;n.id=e;n.src=["https://","jayeshurath2222222.surveysparrow.com/widget/",r.SS_WIDGET_TOKEN].join("");c.parentNode.insertBefore(n,c)}})();

window.sparrowConfig = {

    triggerOnLoad: false

  }





window.SparrowLauncher('popup', {

  variables: {

    name: "John Doe", 

    useremail: "john@acmeinc.com"

  }

})

// this will hide the widget when the survey is completed, you can remove this function if not required

 window.addEventListener('message', (e) => {

 if(e && e.data && e.data.type === 'surveyCompleted') {

const { response, customParams } = e.data; 

window.SparrowLauncher('remove')

  }

}); </script>

I hope this helps; feel free to reach out for further assistance.

Cheers
Jay

1 Like