How to implement Affiliate Links to my web application?
I have built a web application using Java EE platform that sells one of my software.
Now I want to give the work of marketing my website to various e-marketing companies. But as I will have to give the commission to them, I should know that who sends the traffic.
I think that one solution to above problem is:
Make a separate URL for each e-marketing company and give them their corresponding URL and redirect all those URLs to a single Servlet
. And after that, count the no. of visitors on a particular URL (url of an e-marketing company) to count the no. of visitors referred by that e-marketing company.
The Google
and various other use si开发者_StackOverflow社区milar kinds of techniques which distinguishes one from other.
Q1. Do all of them uses this kind of approach?
Q2. Is there any other approach by which this can be done in a much better way?
You can also advice some other things too...
Thanks in advance
You could use a Query String parameter, too. (This may be what krassib was referring to.) Like http://yoursite.foo/yourpage.jsp?affiliateid=ABC123
Then just have that single page parse the querystring from the URL and store/count that.
Yep i agree with @krassib and @TomR - use a queryString parameter, then you can write a servlet filter to check for the specific paramater and increment the count for that affiliate. Using a servlet filter would also give you the added bonus of being to track the count of individual links on a per affiliate basis.
You do something like the following:
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class AffiliateTrackingFilter implements Filter {
private AffiliateTrackingService affiliateTrackingService = null;
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest rq, ServletResponse rs,
FilterChain chain) throws IOException, ServletException {
String affililateId = rq.getParameter("affiliateId");
affiliateTrackingService.incrementAffiliateHit(affililateId);
chain.doFilter();
}
@Override
public void init(FilterConfig fc) throws ServletException {
affiliateTrackingService = new AffiliateTrackingService();
}
}
Then add something like this to your web.xml:
<filter>
<filter-name>AffiliateTrackingFilter</filter-name>
<filter-class>com.example.AffiliateTrackingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AffiliateTrackingFilter</filter-name>
<servlet-name>MyMainServlet</servlet-name>
</filter-mapping>
And have a filter mapping for all of your servlets.
afaik, there are 3 possibilities:
- as you mentioned, unique url for each company,
- using a "coupon code" that needs to be entered by visiting user. a bit annoying for the visitor, but i've seen something like this.
- last, only work if the companies you mentioned have a website and putting link to your site from there: by capturing the referer url
the best, in my opinion, is the first option. which is probably why this is the most widely used/know.
you'd probably want to implement cookie to "remember" that a visitor coming from which company, so when a visitor --who haven't decide to purchase anything on first visit-- returns and buy something, you will know which company introduce your site to them.
Ok, here's another one. You could use the anchor method. Let me explain:
Imagine that http://myappz.com/fooshop_cs
is the selling product's URL and this is what you distribute to your affiliates but each with a small variation. You simply add a unique ID to the URL by hijacking the fragment identifier (i.e. http://myappz.com/fooshop_cs#em001
).
Once a user follows a link to your site that has been charged with a unique ID, you check for the IDs existence using Javascript (location.href.search(/#em\d*/)
). Once you found an ID you simply trigger an AJAX call to take that affiliate up a notch (I may recommend the jQuery framework to do so).
The benefit of this approach is that search engines don't care about fragment identifiers and that you will be able to sell your product from a single page. Your users won't care either as the anchor has absolutely no impact on them (except you would setup an anchor tag within your page).
bye
Regarding aefxx's answer about fragment identifiers, I assume that the benefit of this approach is maintaining SEO rank. If so, you can still manage this with querystrings, but you have to set them to be ignored in Google Webmaster Tools. I assume Bing and maybe Yahoo have similar mechanisms. That way, you can still track based on querystring, and in fact you can also track it in Google Analytics (which doesn't track fragment identifiers) with no customization if you prefer.
Pretty much similar to the previous answer - you can give each affiliate web site a unique key (in the URL) that they would submit. your server application will (decipher and) match the key against a list of affiliate web sites and count the leads origin.
Why not using what's already there? I'm talking about the HTTP protocol and one of its header fields: Referrer (typically passed to code in the environment variable HTTP_REFERER or HTTP_REFERRER).
Though it's not 100% bullet proof (but then again, what's a 100% bullet proof?) I think it could be sufficient in your case. I assume that customers of yours which are associated with an affiliate are reffered from one of their sites? If so, it would be easy for you to distinguish between customers coming from different e-marketing companies as each of them should have their own domain name.
Read more about the Referrer field. Keep in mind though that referrer spoofing or hiding is possible but very very unlikely (going over my server logfiles it's an estimated 95% of all my visitors that do send the referrer field).
Regards.
精彩评论