SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    Halifax, NS, Canada
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Affiliate Tracking - what am I doing wrong?

    Hello,

    I am trying to get an affiliate tracking script to work:

    <script language="javascript"><!--
    var mySearch
    mySearch = location.search.substr(1)

    var expireDate = new Date
    expireDate.setDate(expireDate.getFullYear()+1)

    function setCookie() {
    document.cookie = "id=" + mySearch + "; expires=" + expireDate.toGMTString()
    }
    //-->
    </script>

    For some reason, this is not setting a cookie in my computer when I visit the website liek this: www.crazyhostguy.com?aff250. It should create a cookie for id=aff250. Any ideas what I'm doing wrong? You can see how I've inserted the script here: www.crazyhostguy.com.

    Many thanks in advance!

    Rob.
    CrazyHostGuy.com - Multiple domain hosting in one Plan
    Hosting Plans starting at $1.95/month
    Unlimited Domain Reseller Accounts available
    www.crazyhostguy.com

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've got cookies on - right?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    Halifax, NS, Canada
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    certainly do!
    CrazyHostGuy.com - Multiple domain hosting in one Plan
    Hosting Plans starting at $1.95/month
    Unlimited Domain Reseller Accounts available
    www.crazyhostguy.com

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put a try {} catch(e) {} round it.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    Halifax, NS, Canada
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm afraid I don't know what you mean. I am by no means a Javascript programmer.... I just try to implement scripts that I find

    In this case, I had someone here at SPF help me with this several months ago.... and it worked on my frames page. Now I've redesigned the site and it no longer works. There are no frames anymore, so I removed the parent from parent.location....

    Can I trouble you to re-post the script with your suggestion embedded in it?

    Thanks so much!
    Rob.
    CrazyHostGuy.com - Multiple domain hosting in one Plan
    Hosting Plans starting at $1.95/month
    Unlimited Domain Reseller Accounts available
    www.crazyhostguy.com

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    try {
         document.cookie = "id=" + mySearch + "; expires=" + expireDate.toGMTString();
         }
    catch (e){
         alert(e.type);
         alert(e.code);
         alert(e.description);
         }
    I *think* that they're the right attributes for an error.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •