Web Analytics Made Easy -
StatCounter Need Help!!! tracking where a visitor came from - CodingForum

Announcement

Collapse
No announcement yet.

Need Help!!! tracking where a visitor came from

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need Help!!! tracking where a visitor came from

    Hello all!

    I have currently deployed an online marketing initiative for a web site and I was looking for a way to use javascript to track link-throughs from my online ads. I have been told that it can be done by setting a cookie for the web site visitor(s).

    So, this is the entire process that I am looking at capturing:


    [1]Wall Street Journal online ad - visitor clicks through to my landing page (www.mysite.com/widget)
    [2]My site sets a cookie for that visitor.
    [3]If that visitor goes to my contact page (www.mysite.com/contact) he/she fills out the form and sends it;
    [4]I receive the visitors contact information as well as the destination from where he came from i.e. wall street journal or google.com, etc.


    Here's the code so far that I have. I believe I am basically just getting a cookie and setting it. I need help with transferring the cookie within the contact form.

    Code:
    // this function gets the cookie, if it exists
    function Get_Cookie( name ) {
    
        var start = document.cookie.indexOf( name + "=" );
        var len = start + name.length + 1;
        if ( ( !start ) &&
        ( name != document.cookie.substring( 0, name.length ) ) )
        {
        return null;
        }
        if ( start == -1 ) return null;
        var end = document.cookie.indexOf( ";", len );
        if ( end == -1 ) end = document.cookie.length;
        return unescape( document.cookie.substring( len, end ) );
        
    }
    
    function Set_Cookie( name, value, expires, path, domain, secure ){
    
        // set time, it's in milliseconds
        var today = new Date();
        today.setTime( today.getTime() );
    
        /*
        if the expires variable is set, make the correct
        expires time, the current script below will set
        it for x number of days, to make it for hours,
        delete * 24, for minutes, delete * 60 * 24
        */
        if ( expires )
        {
        expires = expires * 1000 * 60 * 60 * 24;
        }
        var expires_date = new Date( today.getTime() + (expires) );
    
        document.cookie = name + "=" +escape( value ) +
        ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
        ( ( path ) ? ";path=" + path : "" ) +
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ( ( secure ) ? ";secure" : "" );
        
    }
    I appreciate your help in advance!

    BAF :cheers:

  • #2
    google javascript referers. I think thats how you spell it. I think it is somthing simple like

    document.referer;

    But not sure. I know what you are talking about though.
    Single Paradox
    My Site (Under construction)

    Not too bad for a 15 year old

    Comment

    Working...
    X