# Use StatCounter to track visitor paths within your Flash site!

**URL:** https://forum.kirupa.com/t/use-statcounter-to-track-visitor-paths-within-your-flash-site/217501
**Category:** open source
**Created:** [February 27, 2007, 3:28pm UTC](https://forum.kirupa.com/t/use-statcounter-to-track-visitor-paths-within-your-flash-site/217501 "2007-02-27T15:28:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![takethetrain](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@takethetrain](https://forum.kirupa.com/u/takethetrain)
#### Post date: [February 27, 2007, 3:28pm UTC](https://forum.kirupa.com/t/use-statcounter-to-track-visitor-paths-within-your-flash-site/217501/1 "2007-02-27T15:28:16Z")

</div>

My company uses StatCounter to see what sections of our website people tend to visit, but now that we are switching to an all-Flash site, statistics only show the main page (since it is the one that holds the Flash movie). I decided to create a script that would track visitor paths within a Flash movie, and I figured I’d post it here in case anyone else needs something like it.

```auto

function sendClickData(clickVal, titleVal) {

    main_dir = "http://mysite.com/" //The directory where your flash movie is located.
    sc_project = "0000000"; //This should be your project ID, provided by StatCounter.
    sc_security = "00000000"; //Your security ID.

    if(!_global.referrer) {
        _global.referrer = main_dir;
    }
    //You may need to change this c21 to something else depending on the code StatCounter provides.
    sc_base_dir = "http://c21.statcounter.com/t.php?sc_project=" + sc_project;
    sc_url = main_dir + clickVal + ".html";
    sc_tracking_url = sc_base_dir;
    sc_tracking_url += "&resolution=" + scrWidth;
    sc_tracking_url += "&camefrom=" + _global.referrer + "&u="+sc_url;
    sc_tracking_url += "&t="+titleVal;
    sc_tracking_url += "&java=1&security=" + sc_security;
    
    sendVars = new LoadVars();
    sendVars.sendAndLoad(sc_tracking_url, sendVars, "POST");
    sendVars.onLoad = function(success){
        if(success){
            trace ("Data saved")
        }
    }
    _global.referrer = sc_url;
}

```

titleVal is what you want the title of your “page” to be. clickVal is the filename of your “page”, which could also include a subdirectory (“people/bob” would make the fake URL be “[http://mysite.com/people/bob.html](http://mysite.com/people/bob.html)”).

If you are wondering where scrWidth comes from, I appended it to my JavaScript flash embed, with a value of screen.width (to find the user’s screen resolution with JS). If scrWidth is undefined, StatCounter simply won’t know what resolution the user has.

Enjoy! 🙂
