8 Replies Latest reply on Jul 10, 2006 9:07 AM by

    Javascript tracking

      I need to insert a javascript that I got from a search engine analysis company to track the web conversions I get from a lead entry form. Our lead form is written in flash. I need the movie to fire this code when the button is clicked.
      <script language="javascript" src=" http://track.roiservice.com/track/track.aspx?ROIID=93707000032"></script>
      <script language="javascript">
      <!--
      if (typeof(ROIID) + '' != 'undefined') {
      TrackEvent('name', 1, 'project');
      }
      //-->
      </script>

      Can someone please help a flash newbie?

      Thank you,
      Dave
        • 1. Re: Javascript tracking
          jthereliable Level 1
          Put this in an html file:
          <script language="javascript" src=" http://track.roiservice.com/track/track.aspx?ROIID=93707000032"></script>
          <script language="javascript">
          <!--
          function doJavascript()
          {
          if (typeof(ROIID) + '' != 'undefined') {
          TrackEvent('name', 1, 'project');
          }
          }
          //-->
          </script>

          Embed the Flash in the html file, and for the button, put this code:
          getURL("javascript:doJavascript()")

          Hope this helps!
          • 2. Javascript tracking
            Thanks J,
            I put the code in as you suggested. However, instead of going to the last frame it went to the URL in the javascript. I put this on the second to the last frame. Should I put it elsewhere? i tried it in the button action too.
            Dave
            • 3. Re: Javascript tracking
              jthereliable Level 1
              Hmm, I don't specifically understand what you mean by "However, instead of going to the last frame it went to the URL in the javascript." Didn't you want to evoke the javascript?

              Well, if you mean that the javascript sends you somewhere when you click it, then how about on the button, put this:
              on(release)
              {
              getURL("javascript:doJavascript()",_blank)
              }
              It makes a popup instead of changing the window you are on.

              I hope this helps, but if it doesn't, please explain it a bit more.
              1 person found this helpful
              • 4. Re: Javascript tracking
                Hi J,
                Maybe I should explain a bit more. The javascript is a tracking code that when put on an html page, tracks a visitor for search engine analysis purposes. This specific code tracks the conversion or success of the completed form. In this case, the success of a completed lead generation form. All it is supposed to do is send the tracking data captured in the session back to the URL in the JS. When put on an html page, it doesn't actually send the visitor anywhere. It justs works in the background. Is that a better explaination?
                Thanks,
                Dave
                • 5. Re: Javascript tracking
                  jthereliable Level 1
                  Well, not fully. What session do you want to capture? What do you want to send back with Javascript? Why not send it directly using Flash using the loadVars?
                  The thing was, I thought you wanted to run the javascript " (typeof(ROIID) + '' != 'undefined') {
                  TrackEvent('name', 1, 'project');
                  }" so I put it in a function and when you click the button in flash, it runs the javascript.

                  So, explain what you want to send and from where you want to send it. If it's something in Flash to somewhere else, maybe I can write a code of loadVars for you.
                  1 person found this helpful
                  • 6. Re: Javascript tracking
                    I am not fully aware what data the search engine analysis company is retrieving with their javascript. The javascript that I originally mentioned above is what they gave me to put on the HTML pages. It gathers data and passes it back to the URL in the javascript. I don't have to do anything else. My issue is that all of our forms are written in flash. They said that I should be able to insert it into the button action but I am new to flash and don't know the syntax of the javascript compared to the javascript that they gave me. Your resolution seemed to work but it is actually sending the visitor to the URL in the javascript instead of just firing off the javascript being the scenes so to speak and allowing the visitor to continue browsing the site. In this case, after they submit the form, the last frame has an option to view a flash demo.
                    Dave
                    • 7. Re: Javascript tracking
                      jthereliable Level 1
                      Hmm... This is wierd because the javascript
                      function doJavascript()
                      {
                      if (typeof(ROIID) + '' != 'undefined') {
                      TrackEvent('name', 1, 'project');
                      }
                      }
                      is doing something else. I think the TrackEvent() function is doing it, but it has nothing to do with the getURL code.
                      Also, did you try the popup one? If that works and you don't mind about a popup, try that one. I'm not sure why it would redirect you because the getURL with the javascript is the same thing as a <a href="javascript:doJavascript()">Button</a> tag. Try putting this link and clicking it. If it does link you elsewhere, I don't think Flash is doing it anymore, you should ask the search engine analysis company.
                      If it doesn't change the URL, then I'm confused...

                      But still, I suggest putting it into a pop up because you don't want it to change sites.

                      (I think that the javascript function TrackEvent sends the info, whatever it maybe, using javascript to another site. And by doing that, they need to change the site)
                      • 8. Re: Javascript tracking
                        Thanks for you help. I was on vacation and am now just getting back to finishing this.
                        I did as you said and set the getURL to _blank so that it opens a new window. The pages all work now but the conversion tracking doesn't register. I think I know why. The new window opens and closes immediately. Flash is calling the doFunction but it isn't on the _blank page. It is on the HTML page that called the Flash in the first place. Therefore, the getURL isn't seeing it, right?