ASP Code
  Home arrow ASP Code arrow Ad Tracking URL Hits
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP CODE

Ad Tracking URL Hits
By: Steve Schofield
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 46
    2003-06-22

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Here is the ad tracking I've used on occasion from http://aspfree.com. This has a stored procedure, two tables (one for tracking hits by day and by vendor, second for just storing info about the vendor). I've also used an ASPX page to grab the request.querystring, record to the database and then redirect the user to the particular link. When you write out the hyperlink programmatically or by hand goes something like HTTP://YOURDOMAIN.COM/TA.ASPX?V=1. Downloadable code available!

    Here is the ad tracking I've used on occasion from http://aspfree.com. This has a stored procedure,
    two tables (one for tracking hits by day and by vendor, second for just storing info about the vendor).
    I've also used an ASPX page to grab the request.querystring, record to the database and then redirect the
    user to the particular link. When you write out the hyperlink programmatically or by hand goes something
    like HTTP://YOURDOMAIN.COM/TA.ASPX?V=1

    STORED PROCEDURE
    CREATE PROCEDURE dbo.sp_AdCompanyUrl ( @cId int, @URL varchar(255) OUTPUT ) AS Declare @chkRecord int Declare @numOfHits int Declare @dateSubmitted datetime set @dateSubmitted = convert(char(10), getDate(), 101) If exists (select cId from adCompanyHits where dateSubmitted = @DateSubmitted and cId=@cId) begin set @numOfHits = (select numOfHits from adCompanyHits where cId = @cId and dateSubmitted=@dateSubmitted) + 1 UPDATE adCompanyHits SET numOfHits = @numOfHits WHERE cId = @cId and dateSubmitted=@dateSubmitted end ELSE INSERT INTO adCompanyHits(cId, DateSubmitted) VALUES (@cId, @DateSubmitted)
    /* I think one could use set @numOfHits = SELECT @@SCOPEIDENTITY */
    SELECT URL FROM adCompanyInfo WHERE cId = @cId RETURN GO TABLES FOR STORING INFO TABLE 1 - ACTUALLY STORES INFO ON VENDOR AND NUMBER OF HITS BY DATE CREATE TABLE [dbo].[adCompanyHits] ( [id] [int] IDENTITY (1, 1) NOT NULL , [cId] [int] NULL , [DateSubmitted] [datetime] NULL , [NumOfHits] [int] NULL ) ON [PRIMARY] GO TABLE 2 - STORES COMPANY INFO ABOUT WHO YOUR DOING ADVERTISING WITH CREATE TABLE [dbo].[adCompanyInfo] ( [cId] [int] NOT NULL , [Company] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [URL] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [startDate] [datetime] NULL , [endDate] [datetime] NULL , [adDescription] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [titleDescription] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Contact_Name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Contact_Email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] GO 'code for TA.ASPX or whatever you want to name the page.

    /*I use TA for 'track ad' 'this could also be re-arranged to use an ASP pages. */
    <!--asp@ Page Language="vb" -->
    <!--asp@ Import Namespace="System.Data" -->
    <!--asp@ Import Namespace="System.Data.SQLClient" -->
    <script language="vb" runat="server">
    Sub Page_Load(sender As System.Object, e As System.EventArgs)

    'Grab the info from querystring
    dim v as integer = Trim(Left(request.querystring("v"), 1))

    If Len(v) > 0 Then
        'GET YOUR CONNECTION STRING FROM WEB.CONFIG
        Dim conn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("DSN"))
        Dim cmd As SqlCommand = New SqlCommand("sp_adCompanyUrl", conn)
        cmd.CommandType = CommandType.StoredProcedure

        Dim workParam As SqlParameter = Nothing

        cmd.Parameters.Add(New SqlParameter("@cId", SqlDbType.Int, 4))
        cmd.Parameters("@cId").Value = v

        workParam = cmd.Parameters.Add(New SqlParameter("@URL", SqlDbType.VarChar, 255))
        workParam.Direction = ParameterDirection.Output

        conn.Open()
        Dim strID As string = cmd.ExecuteScalar()
        If conn.State = ConnectionState.Open Then
            conn.Close()
        End If
        'Response.Write(strID)  used for testing writing out the number.
        Response.Redirect(strID) 'Put user code to initialize the page here
    End If
    End Sub
    </script>


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP Code Articles
    More By Steve Schofield

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! IBM – Taking Web 2.0 to Work

    David Barnes, Lead Evangelist for IBM Emerging Internet Technologies will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! Application Development Tools for the Mainframe Developer

    You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months.
    FREE! Go There Now!


    NEW! Download DB2 Express-C 9.5

    Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages.
    FREE! Go There Now!


    NEW! Push RSS to new limits

    This tutorial presents an innovative use of the well-known Really Simple Syndication (RSS) format's associative properties to emulate the functionality of a simple relational database. It demonstrates using RSS channels to store contact information and meeting information -- much as a personal address book and calendar does. It uses RSS elements and attributes such as items and guids to create a neural-network-like mesh of related data.
    FREE! Go There Now!


    NEW! Rational 'Talks to You' Teleconference Series

    This Fall, IBM Rational talks to you directly through a special teleconference series giving you access to the best minds in IBM Rational - product experts and market thought leaders who will answer your questions during these pre-scheduled telephone conference calls. Register today!
    FREE! Go There Now!


    NEW! The role of integrated requirements management in software delivery

    This paper is about the critical role that a discipline called integrated require­ments management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrat­ing, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Performance Tester V7.0.1

    Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads.
    FREE! Go There Now!


    NEW! Try IBM Rational Asset Manager V7.0 online!

    You can now evaluate IBM Rational Asset Manager V7.0 online without installing or configuring it on your own system! Rational Asset Manager helps create, modify, govern, find, and reuse any type of development assets, including SOA and systems development assets. Rational Asset Manager helps you reduce software development costs and improve quality by facilitating the reuse of all types of software development-related assets. Visit developerWorks to learn more about this product and register to explore its capabilities online.
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for Connectivity

    Visit IBM developerWorks to try the IBM SOA Sandbox for connectivity. The SOA Sandbox for connectivity provides a trial environment with the tooling and components to help you explore how to effectively connect your infrastructure and integrate all of the people, processes and information in your company. Use the hosted sandbox to explore SOA techniques that streamline connecting existing IT assets together, as well as learn how to connect them to new business logic.
    FREE! Go There Now!


    NEW! Webcast: Eclipse: Empowering the universal platform

    The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP CODE ARTICLES

    - ASP Forms
    - ASP: The Beginning
    - Getting Remote Files With ASP Continued
    - Inbox and Outbox Manipulation in ASP
    - Relational DropDownList Using VB.NET
    - Ad Tracking URL Hits
    - Use ViewState to display one record per page...
    - Send Email using ASP.NET formatted in HTML
    - ASP File Explorer
    - ASP/XML Interview questions by Srivatsan Sri...
    - Various methods of setting Date values to a ...
    - Conditional DataGrid Item and using checkbox...
    - Fill .NET Listbox with SQL DataReader
    - Filling Dropdown box using Code-Behinds in C#
    - FLAMES code sample written in .NET What is F...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway