From June 7 through June 18, we will be performing minor community maintenance. As a result, email notifications may not send during this time. We apologize for any inconveniences!
You may have noticed the url for our site changed, as we are preparing to launch our community redesign. Stay on the lookout for details coming soon, and be sure to update your bookmarks!

Adding Javascript?

acoganacogan Community Member Qubie ✭

Adding Javascript?

Hello! I am new to computer programming and hoping to figure out how to add some Javascript to the survey I'm running for my lab.

I got the code from here:

grecaptcha.ready(function() { grecaptcha.execute('_reCAPTCHA_site_key_', {action: 'homepage'}).then(function(token) { ... }); });

When I try to save the pasted code into the "Add Javascript" box, I get an error message ("Unexpected token <"). Clearly I'm out of my depth, but my hope is that getting this code to work with our survey might be a fixable problem. I think this bot-detection functionality may be available on Qualtrics, but our school account doesn't seem to have access to this user-friendly version of the feature.

I would so appreciate any help or advice you can spare. Thank you for your time!


Best Answer

  • KoalaTricksKoalaTricks BostonCommunity Member Guru ✭✭
    Accepted Answer

    It sounds like you pasted all of the code from the first snippet at the URL, which is HTML (it has the <>) and not pure JavaScript.

    You would want to put the first line in the header of your survey (the source editor, not the WYSIWIG editor):

    <script src=""></script>

    And then only this part on the question-level "Add Javascript" where you want it to appear. I am assuming you already have the requisite site key and token -- it won't work otherwise.

    grecaptcha.ready(function() {
        grecaptcha.execute('_reCAPTCHA_site_key_', {action: 'homepage'}).then(function(token) {


Sign In to Comment