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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 48
    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


    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! A Layered approach to delivering security-rich Web applications

    As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper.
    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 a free trial of WebSphere Business Modeler Advanced V6.1.1

    Visit IBM developerWorks to download a free trial version of WebSphere Business Modeler Advanced V6.1.1, IBM’s premier business process modeling and analysis tool for business users that offers process modeling, simulation, and analysis capabilities. IBM WebSphere Business Modeler helps you visualize, understand, and document business processes for continuous improvement.
    FREE! Go There Now!


    NEW! Download the free Web Application Security eKit

    Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications.
    FREE! Go There Now!


    NEW! Evaluate IBM Rational Software Analyzer V7.0

    Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle.
    FREE! Go There Now!


    NEW! Rational Asset Manager eKit

    Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions.
    FREE! Go There Now!


    NEW! Rational Build Forge Express eKit

    Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast.
    FREE! Go There Now!


    NEW! Trial download: IBM Informix Dynamic Server Express Edition V11.0

    Informix Dynamic Server (IDS) Express Edition offers outstanding online transaction processing (OLTP) database performance, while helping to simplify and automate many of the tasks associated with deploying databases for small business applications. IDS 11 further extends the ease of management and applications integration with the Admin API and Scheduler, high availability with Continuous Log Restore for backup server recovery in case of a primary server failure, and column level encryption to protect personal and company private data.
    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! Try the IBM SOA Sandbox for People

    Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity.
    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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek