Tracking cookies enable the owner of a Web site to obtain information from visitors to his or her site. The Web site's owner can use the information to learn more about visitors and/or provide visitors with a more personalized and streamlined experience. For example, a cookie can store a Web site visitor's user name and password so the visitor does not have to populate this information every time he or she visits the Web site, saving the visitor time.

Steps

  1. 1
    Plan on what information you want your cookie to collect. Before you make a tracking cookie, you should determine what type of information you want to track from visitor's to your Web site. For instance, you may find it important to know the zip code of a person visiting your Web site if your Web site sells products that require shipping costs and certain sales taxes.
  2. 2
    Use HTML. If you have created your Web site using HTML code and are somewhat familiar with programming, you can make a tracking cookie from scratch.
    • Use the “Response” command to write a cookie on a visitor's computer. “Response.Cookies(“CookieName”)=value” is the most basic form of this code. The code: “Response.Cookies("VisitorName")=Request.Form("UserName")” would allow you to keep track of a visitor's user name.
    • Use the “Request” command to retrieve the cookie. “Request.Cookies("CookieName")” would allow you to retrieve the information from the visitor's computer when the visitor returned to your Web site.
    Advertisement
  3. 3
    Note however that standard HTML does not have commands. "Response" and "Request" are part of Microsoft's ASP (active server pages). See http://www.w3schools.com/asp/coll_cookies_response.asp If your web server does not support ASP, you'll have to investigate other methods of generating cookies, such as CGI scripts or PHP.
  4. 4
    Consider tracking cookie software as an alternative to writing your own code. There are software programs out there that will do the heavy coding for you.
    • Software will allow you to make certain kinds of cookies; sometimes a single type of software will only allow you to make a specific cookie. Some of this software is considered “freeware,” and thus won't cost you anything. Tracking cookie software can help with restricting how many times a visitor can download software from your Web site by remembering that the software was already downloaded.
  5. 5
    Add security to your cookie. Internet security is a key concern of most Internet users. It’s important to provide security so that visitors' information is protected.
    • A domain property will restrict the cookie from being read by another Web site. A sample of the code for this is: Response.Cookies("CookieName").Domain = "www.mydomain.com"
    • A path property restricts the cookie to being read by a specific path. A sample of the code for this is: Response.Cookies("CookieName").Path = "/maindir/subdir/path"
  6. 6
    Give your cookie an expiration. A cookie will expire once the Web browser the visitor uses to view your Web site is closed. An expiration date must be set if you want to store the cookie so that when the user comes back the information is saved. An example of this code is: Response.Cookies("CookieName").Expires=#January 01, 2010# (assuming a January 01, 2010 expiration date).
  7. Advertisement

Community Q&A

  • Question
    Can someone track if I just look at a picture they posted?
    Community Answer
    Community Answer
    The web-server can if it has implemented a method to do so, such as cookie tracking. It depends on the site.
  • Question
    Do I have a unique code on my mobile phone?
    Community Answer
    Community Answer
    If you mean the advertising ID, then yes, your phone has one (although this is usually for apps). You can reset this in settings.
  • Question
    What does a cookie look like?
    Living Concrete
    Living Concrete
    Top Answerer
    A cookie is typically invisible to a user. You have to use special tools to view it. If you use something like Chrome Dev Tools or Firebug to view a cookie, you'll see that it is actually just a key-value pair.
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 12 people, some anonymous, worked to edit and improve it over time. This article has been viewed 116,886 times.
How helpful is this?
Co-authors: 12
Updated: May 6, 2021
Views: 116,886
Categories: Programming
Advertisement