Showing posts with label program. Show all posts
Showing posts with label program. Show all posts

Saturday, March 31, 2012

Theory : How to implement an afilliate program website.

I have a website, and I want that when someone comes from an affilliate and buy something in my site, automatically generate a comission to the affiliate.

I would like to know if anyone know any documents, articles or source code to study a little in order to implement this.

Just to say that I'm a ASP.NET newbie with few "navigation hours".

Thank you.regardless of asp.net, you can use several methodologies to incorporate affilliate tracking. The best one (in my opinion) would be to simply track the affilliate by passing around their value in the querystring (ie: mysite.com/page.aspx?aff=2343444)

Then you can look for this number -- say when a user submits a form to purchase an item.
OK. I'll avoid any discussion around more complex methods of handling the same functionality, and describe in terms of pages, session etc.

How about:

- Create an incoming page that can decode an incoming affiliate request.
e.g. http://www.mysite.com/affprogramme.aspx?affid=<insert id here>&sku=<product id here>
The page will:
- Set the session to the affiliate id, which is then recorded when items are placed in the cart.
- Redirect the incoming request to the appropriate product.

Then, when an order is placed, it's easy to pull a report based on affiliate purchases.

Be aware that this is open to abuse for click through payments.

Anyway, it's a start of a more refined solution.

Hope it helps,
Why not just pass the affiliate id in the querystring as opposed to keeping it in a session? Im asking because 90+% may not order, so why even look at that value until an order has been placed? (unless you want to track each page, even then why not just use the querystring.)

although I'm not that stingy with Sessions, imagine 50,000 users going to your site on a good month.

Either way both methods would work (just putting in my .02)
Thank you all for your "opinion" :

Question :
It is best to save the affiliate ID code in the cookie ?

Why ? Because if the user have been redirected to my page trough an affilliate link, and want to become later to buy something , he will type my direct address (www.mysite.com) without the affiliate link. I think I should know (remember) what affiliate have indicated my webpage.

What you think about this ?

Thank you.
Good point! But what if the user does not accept cookies?

hmmm... always something to think about.

I think the best way would be:

- Persist to cookie if user accepts cookie
- Use QueryString if not

if user does not accept cookies and goes back to the site by typing the url directly the affiliate would not get paid... hmmmm.
I should use both I think :

I should use the :
www.mysite.com/affiliates.aspx?affid=<insert id here
And use this affid to fill the cookie.

If the user don't accept cookies ... the affiliate don't win a comission ... sound right or not ?
Well, this could be a commercial issue.
What defines an affiliate 'sale'? Is it if a purchase is made from your site in the next session, 20 days, 30 days and so on.
This is what defines the use of cookies and the like.
The page will not sell products, will sell services.

Possible customers can bought the service now, today, next month or never. If he buy the service, until he's an active customer the "affiliate" will win comission of sale.

This is important to keep the affiliate information much time as possible.

What do you think ?
Technically, I think it's fine.
Commercially, I think that's a pretty good deal for your affiliates.

Cheers,
Commercially is a great deal for me too.
Imagine ... you will have a "free" comercial team.

Don't have problem paing 10% of comission to anyone that gives me a new customer (the rest of the profit is all mine). In this mode it is more simple to anunce my services. Just to say that the customer pay monthly for the service ... the affiliate will won the comission montly too.

Thank you all for your technical help.
Don't use affiliate.aspx?affiliateID=XXXX

If I find a link like that I'll manually go out of my way to simply type in the main URL into another window without the affiliate info.

However if it were something less obscure such as in.aspx?in=XXXX I don't know if it's an affiliate in link or simply a link exchange hit counter or a redirect so I'll just click and leave it.
Jake,

Thank you for you nice idea. I allways do the same but forget that detail.

Best regards,
also you could always:

1.) Create the link with the reseller Id in the page name (without having to create the page)..

ie: www.myDomain.com/res1233.aspx

Then create a custom handler to convert the res1233.aspx to an actual page (from the ASP.NET pipeline) while capturing the affiliate reference at the same time.

:-)
Although technically since you will be the owner of the affiliate program if people did what I do (just type in the base URL without affiliate code) it would benefit you as you wouldn't be paying out any commissions on those sales..

Monday, March 26, 2012

This is an ASP.NET complite program and it works fine. An error is genereded if

Hi,

Following is an ASP.NET complite program and it works fine. An error is genereded if there is one record at the last page of the DataGrid.
Here is the error generated by the system System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.
is there any way to fix this problem?

Here's the Code:
<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SQLClient" %>
<html>
<head>
<meta name="GENERATOR" Content="ASP Express 2.1">
<title>Deleting from DataBase using a DataGrid</title>
<script language="VB" runat="server">

Sub MyDataGrid_DeleteCommand(s As Object, e As DataGridCommandEventArgs )
Dim strConn as String = "server=YourServer;uid=YourUID;pwd=YourPWD;database=YourDB"
Dim DeleteCmd As String = "DELETE from safetable Where id = @dotnet.itags.org.Id"
Dim MyConn as New SQLConnection(strConn)
Dim Cmd as New SqlCommand(DeleteCmd, MyConn)
Cmd.Parameters.Add(New SqlParameter("@dotnet.itags.org.ID", MyDataGrid.DataKeys(CInt(e.Item.ItemIndex))))
MyConn.Open()
Cmd.ExecuteNonQuery()
MyConn.Close()
BindData
End Sub

Sub Page_Change(sender As Object, e As DataGridPageChangedEventArgs)
MyDataGrid.CurrentPageIndex = e.NewPageIndex
BindData
End Sub

Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Sub BindData()
Dim strConn as String = "server=YourServer;uid=YourUID;pwd=YourPWD;database=YourDB"
Dim MySQL as string = "Select * from safetable Order by id desc"
Dim MyConn as New SQLConnection(strConn)
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,MyConn)
Cmd.Fill(ds,"safetable")
MyDataGrid.Datasource=ds.Tables("safetable").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
</head>
<body>
<form runat="server" method="post">
<asp:Datagrid runat="server"
Id="MyDataGrid"
GridLines="Both"
cellpadding="0"
cellspacing="0"
Headerstyle-BackColor="#8080C0"
Headerstyle-Font-Name="Arial"
Headerstyle-Font-Bold="True"
Headerstyle-Font-Size="14"
BackColor="#8080FF"
Font-Name="Arial"
Font-Size="11"
AlternatingItemStyle-BackColor="#C0C0C0"
AlternatingItemStyle-Font-Name="Arial"
AlternatingItemStyle-Font-Size="11"
BorderColor="Black"
AllowPaging = "True"
PageSize = "8"
PagerStyle-Mode = "NumericPages"
PagerStyle-HorizontalAlign="Center"
PagerStyle-PageButtonCount = "10"
OnPageIndexChanged = "Page_Change"
AutogenerateColumns="False"
OnDeleteCommand="MyDataGrid_DeleteCommand"
DataKeyField="id"
Width="50%">
<Columns>
<asp:ButtonColumn Text="Delete" HeaderText="Delete" CommandName="Delete"></asp:ButtonColumn>
<asp:BoundColumn DataField="fname" HeaderText="fname"></asp:BoundColumn>
<asp:BoundColumn DataField="lname" HeaderText="lname"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</form>Here is the table structure for SQL

CREATE TABLE [safetable] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[fname] [char] (10) NULL ,
[lname] [char] (10) NULL
) ON [PRIMARY]
GO
Sub Page_Change(sender As Object, e As DataGridPageChangedEventArgs)
Dim pageIndex As Integer
If e.NewPageIndex >= 0 And e.NewPageIndex < MyDataGrid.PageCount
' Valid page index.
pageIndex = e.NewPageIndex
Else If e.NamePageIndex < 0
' Move to the first page.
pageIndex = 0
Else
' Move to the last page.
pageIndex = MyDataGrid.PageCount
End If

MyDataGrid.CurrentPageIndex = pageIndex
BindData
End Sub
Thanks for your support but I am getting same error. When I am at the last page on the datagrid, there is only one record is shown. I delete that record and it is deleted successfully. Since there is no data to show on the last page of the datagird, system cannot bind it. Thats why I am getting this error. After deleting the last record on the last page of the datagrid, it should display previous page.
Same solution... :)
Move the code in the Page_Change event into a separate function, and use that function only to DataBind(), then add calls to that function in both Page_Change and MyDataGrid_DeleteCommand events.
Your solution is not clear to me! Is there any way that you can create a sample?

Thanks
It's untested, but should work.

Sub MyDataGrid_DeleteCommand(s As Object, e As DataGridCommandEventArgs )
Dim strConn as String = "server=YourServer;uid=YourUID;pwd=YourPWD;database=YourDB"
Dim DeleteCmd As String = "DELETE from safetable Where id = @.Id"
Dim MyConn as New SQLConnection(strConn)
Dim Cmd as New SqlCommand(DeleteCmd, MyConn)
Cmd.Parameters.Add(New SqlParameter("@.ID", MyDataGrid.DataKeys(CInt(e.Item.ItemIndex))))
MyConn.Open()
Cmd.ExecuteNonQuery()
MyConn.Close()
BindData
End Sub

Sub Page_Change(sender As Object, e As DataGridPageChangedEventArgs)
MyDataGrid.CurrentPageIndex = GetValidPageIndex(e.NewPageIndex)
BindData
End Sub

Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Sub BindData()
Dim strConn as String = "server=YourServer;uid=YourUID;pwd=YourPWD;database=YourDB"
Dim MySQL as string = "Select * from safetable Order by id desc"
Dim MyConn as New SQLConnection(strConn)
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,MyConn)

Cmd.Fill(ds, "safetable")
With MyDataGrid
.Datasource = ds.Tables("safetable").DefaultView
.CurrentPageIndex = GetValidPageIndex(.CurrentPageIndex)
.DataBind()
End With
End Sub

Function GetValidPageIndex(ByVal intCurrentIndex As Integer) As Integer
Dim pageIndex As Integer
If e.NewPageIndex >= 0 And e.NewPageIndex < MyDataGrid.PageCount
' Valid page index.
pageIndex = e.NewPageIndex
Else If e.NamePageIndex < 0
' Move to the first page.
pageIndex = 0
Else
' Move to the last page.
pageIndex = MyDataGrid.PageCount
End If
End Function
Hi,

Is it posible that you can take a look at the your function GetValidPageIndex?. I had a error with it.
I made some modification to your function GetValidPageIndex and I still get error. Here is the code that I made modification.

Function GetValidPageIndex(ByVal intCurrentIndex As Integer) As Integer
Dim pageIndex As Integer
If intCurrentIndex >= 0 And intCurrentIndex < MyDataGrid.PageCount
' Valid page index.
GetValidPageIndex = intCurrentIndex
Else If intCurrentIndex < 0
' Move to the first page.
GetValidPageIndex = 0
Else
' Move to the last page.
GetValidPageIndex = MyDataGrid.PageCount
End If
End Function
I add following code and It worked fine.

Dim Result As Integer = MyDataGrid.Items.Count Mod MyDataGrid.PageSize

If Result = 1 Then
MyDataGrid.CurrentPageIndex = ( MyDataGrid.PageCount - 2)
End If