title: Trying to make my xAPI statement dynamic
body: <p>I have an application where someone logs in with their full name and email address. I capture that information with HTML5's local storage. I want to then use xAPI Youtube Video tracker to send messages to the LRS. I'm having trouble with the code that places the local storage variable into the actor statement. When I hard code a name and email address, it works fine. When I try and pull it from local storage it says "no way." Can you look at my offending code and tell me where I'm going wrong? I commented what does work and what doesn't work is right below it. Many thanks.</p>
  
  <pre><code>var name = localStorage.getItem('name');
      var email = localStorage.getItem('email');  
      var video = "RXsHnGyVddg"; // Change this to your video ID
  
      // "global" variables read by ADL.XAPIYoutubeStatements
      ADL.XAPIYoutubeStatements.changeConfig({
        //"actor":  {"mbox":"mailto:molly.fisher@example.com", "name":"Molly Fisher"},
        "actor":  {"mbox":"mailto:" + email, "name": + name},
        "videoActivity": {"id":"https://www.youtube.com/watch?v=" + video, "definition":{"name": {"en-US":video}} }
      });
  
      function initYT() {
        var tag = document.createElement('script');
        tag.src = "https://www.youtube.com/iframe_api";
        var firstScriptTag = document.getElementsByTagName('script')[0];
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
      }
  
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          height: '390',
          width: '640',
          videoId: video,
          playerVars: { 'autoplay': 0 },
          events: {
            'onReady': ADL.XAPIYoutubeStatements.onPlayerReady,
            'onStateChange': ADL.XAPIYoutubeStatements.onStateChange
          }
        });
      }
  
      initYT();
  
  
      // Auth for the LRS
      var conf = {
          "endpoint" : "https://lrs.adlnet.gov/xapi/",
          "auth" : "Basic " + toBase64("xapi-tools:xapi-tools"),
      };
  
      ADL.XAPIWrapper.changeConfig(conf);
  
      /*
       * Custom Callbacks
       */
      ADL.XAPIYoutubeStatements.onPlayerReadyCallback = function(stmt) {
        console.log("on ready callback");
      }
  
      // Dispatch Youtube statements with XAPIWrapper
      ADL.XAPIYoutubeStatements.onStateChangeCallback = function(event, stmt) {
        console.log(stmt);
        if (stmt) {
          stmt['timestamp'] = (new Date()).toISOString();
          ADL.XAPIWrapper.sendStatement(stmt, function(){});
        } else {
          console.warn("no statement found in callback for event: " + event);
        }
      }
  </code></pre>