为您的网站创建广告系统(我自己的 AdSense)

发布于 2024-09-14 15:16:46 字数 279 浏览 4 评论 0原文

我不知道正确的术语,但我说我想在我的网站上投放广告,只要用户点击网站,广告商就需要付费。应该怎样做呢?

我的方法是将广告链接到一个脚本文件,该文件将在数据库中记录点击并将用户重定向到广告商的网站。我看到了这一点的一个弱点;同一用户在一段时间内可以多次点击广告,多次点击将被记录。

因此,为了避免这种情况,我正在考虑为每个访问者设置一个COOKIE,并且每个访问者的点击每天只会记录一次。 (但是如果 cookie 被禁用怎么办)。

在网站上建立这样的广告系统的正确方法是什么?您能分享您的方法吗?

I do not know the right term for this but say I want to have Ads on my web sites where there advertisers need to pay whenever users click on the web sites. How should one go about doing this?

My approach is to link the Ad to a script file that will record the click in a database and redirect the user to the advertiser's site. I see one weakness with this; the same user can click the Ad multiple times within a timeframe and multiple clicks will be recorded.

So to avoid that, I am thinking of setting a COOKIE for each visitor and each visitor's click will be recorded only once in a day. (But what if cookie is disabled).

What is the right way to set up an advertisement system like this on a web site? Can you share your methodologies?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

萌︼了一个春 2024-09-21 15:16:46

我最近创建了这样一个系统,请查看其推广网站textsensor.com
那么我们该如何做到这一点,您需要记住以下几点

1) 不允许跨域 ajax,因此当某些用户点击可能出现在任何发布商和您的网站中的广告时,不会向您的服务器发送数据可能会有数千人。

2) Cookie 可能会像您所说的那样被阻止,而且不同的浏览器可能会导致不同类型的麻烦:) 当您在这种情况下处理 Cookie 时。

3) 您需要向发布商提供脚本标签,以便他们在网站上嵌入相关关键字的广告。

4) 该标签必须执行服务器端编程语言。例如

<script src="http://dennis.com/ads_application/get_my_ads.php">

如果您有多个 php 文件,则包含 1 个 js 文件,该文件会将所有 php 文件导入网站,例如

    <script type="text/javascript" src="http://www.dennis.com/ad_application/inline.js">
</script>

5) 您需要告诉服务器有关发布者的信息,因此请在其中输入 id 和营销活动 id在 script 标签内,并将该脚本标签放在第 4 站的 inline.js 文件之前。

<script type="text/javascript">
 var ad_publisher = "5122";
 var ad_campaign = "11129";
 var ad_type = "inline";
</script> 

6) 您需要检查当前主机是否有资格在该网站上投放广告

7) 您可以查看示例 inline.js 文件 这里是我们为 textsensor.com 制作的

8) 为了创建最后一个用户点击广告之间的间隔,您需要通过创建 cookie 来记录该用户使用的 IP 地址。这必须在服务器端完成,即将 IP 地址和用户点击广告的时间发送到服务器。

I recently created such a system, please view its promotion site textsensor.com.
So how do we do that, you need to keep these points in mind

1) Cross domain ajax is not allowed so no sending data to your server when some user click on a ad that could be present in website of any of the publisher and you might got them in thousands.

2) Cookies might be blocked like you said, also different browsers might cause different sort of trouble :) when you deal with cookies in such scenarios .

3) You need to provide publisher with script tag that they will embed ads on there website for relevant keywords.

4) This tag must be executing server side programming language. for example

<script src="http://dennis.com/ads_application/get_my_ads.php">

OR if you have multple php files then include 1 js file that will import all php files into the website for example

    <script type="text/javascript" src="http://www.dennis.com/ad_application/inline.js">
</script>

5) you need to tell server about publisher, so put there id and there campaign id inside script tag and put that script tag before inline.js file from stop 4.

<script type="text/javascript">
 var ad_publisher = "5122";
 var ad_campaign = "11129";
 var ad_type = "inline";
</script> 

6) you need to check whether current host is eligible for putting ads on there website

7) you can view sample inline.js file here we made for textsensor.com

8) For creating interval between when last user clicked on an ad, you need to record that user using there ipaddress and by creating cookies. that must be done on server side, that is send ipaddress to the server and time user clicked on the ad.

北凤男飞 2024-09-21 15:16:46

您可以将用户的 IP 地址记录在缓存或数据库中,以防止一天内多次点击。

You could record the user's ip address in cache or in the database to prevent multiple clicks in a one day period.

可是我不能没有你 2024-09-21 15:16:46

广告商需要完全相信您提供的数字是正确的。这就是为什么广告空间被 doubleclick、google 和其他庞然大物所主导。在担心技术方面之前,我会确保您可以通过进行一些市场研究来填充广告。

假设您已经这样做了,那么您确实可以使用 cookie。

您还可以为每个广告提供唯一的网址。因此,如果同一个网址被点击两次,那么您就知道用户点击了同一个广告两次。

即使您的网站上只有 1 个广告,它也始终会附加一个 GUID 或其他内容,以便您知道这是一次独特的点击。

祝你好运。

Advertisers need to have total trust that you are giving them the right numbers. That's why the ad space is dominated by the likes of doubleclick, google and other behemouths. I'd make sure you can fill your ads by doing some market research before worrying about the technical aspect.

Assuming you have already done this, you can indeed use a cookie.

You can also serve a unique URL with every ad. So if the same URL is clicked twice, then you know a user is clicking the same ad twice.

Even if you have only 1 ad on your site, it would always have a GUID or something attached so you know it was a unique click.

Good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文