简体   繁体   English

在javascript中管理到多个站点的广告

[英]manage ads to multiple sites in javascript

Is there a way to manage ads in a way that if i choose to show a certain ad, it will show to multiple sites that publish my ads in their sites. 有没有一种方法可以管理广告,如果我选择展示某个广告,它将展示给在其网站上发布我的广告的多个网站。 I'm looking into adding google analytics to add tracking. 我正在考虑添加Google Analytics(分析)以添加跟踪。

I've looked into iframes but there are security issues. 我研究了iframe,但存在安全问题。

Is there a way to accomplish this with javascript, just like how google adsense works? 有没有一种方法可以使用javascript完成此操作,就像google adsense的工作方式一样? I was thinking of having some javascript and giving my publishers remote scripts to access the data. 我当时在考虑使用一些JavaScript,并为我的发布商提供远程脚本来访问数据。

Or is there a better way? 或者,还有更好的方法?

I'm don't want to use php because it is likely that the publishers are not using php and having a php script that pulls the data means it will not execute for sites that are in html. 我不想使用php,因为发布者很可能没有使用php,并且有一个php脚本来提取数据,这意味着它不会对html站点执行。

SUMMARY: I'm looking for a solution thats in html and js. 简介:我正在寻找html和js中的解决方案。 Any help is appreciated, and sudo code is always helpful if you can provide some. 感谢您提供任何帮助,如果您可以提供帮助,sudo代码总是很有帮助的。

Thanks in advance 提前致谢

I worked at a spot that used javascript in order to render ads. 我在一个使用javascript来渲染广告的地方工作。 This is how I accomplished it. 这就是我完成它的方式。

First, server type. 首先,服务器类型。 I was running an NGINX web server with a PHP-FPM backend, with Varnish (cache) in front of it. 我正在运行一个具有PHP-FPM后端的NGINX Web服务器,并在其前端使用了Varnish(缓存)。 The server was basically serving up static files, so this kept server load tremendously low. 服务器基本上是在处理静态文件,因此这使服务器负载非常低。 This is a decent tutorial for setting that up on CentOS 这是在CentOS上进行设置的不错的教程

I used an Amazon Elastic Beanstalk, small instance type, to run this. 我使用小型实例类型的Amazon Elastic Beanstalk来运行它。 It never needed to spin up more than one Small instance to serve somewhere in the neighborhood of 2.5MM javascripts per hour. 它不需要旋转一个以上的Small实例来每小时以大约2.5MM的javascript服务。 Keep in mind, it's just serving small text snippets. 请记住,它只是提供小的文本片段。

The tags looked like this: 标签看起来像这样:

<script type="text/javascript" src="http:/ads.someserver.com/1234"></script>

Where the [1234] was the tag ID number. 其中[1234]是标签ID号。 Each publisher could have multiple tags, the ID keeps track of what publisher, ad size it is, etc. 每个发布者可以有多个标签,ID可以跟踪发布者的名称,广告大小等。

Second, javascript. 其次,javascript。 So now, you use an nginx rewrite in order to direct that request to a javascript file, which then in turn loads up the ad. 因此,现在,您使用nginx重写将请求定向到javascript文件,然后依次加载广告。 The javascript file has to dynamically (and without libraries of any kind, load time is at a premium) create an HTML element , and then fill it with your ad. javascript文件必须动态创建(并且没有任何类型的库,加载时间非常宝贵) 创建HTML元素 ,然后用您的广告填充它。

You need to have another service of some kind choose what ad gets shown. 您需要其他某种服务来选择显示什么广告。 This was not my department, but loading something up once you have the ID should not be difficult. 这不是我的部门,但是一旦有了ID,就可以加载一些东西。

Figuring out where you should serve the assets (the ads) from is a tough call to make. 弄清楚应该从何处投放资产(广告)是一项艰巨的任务。 Wherever you serve it from, better be super fast, because ad servers nowadays that you'll be competing against are super fast, and publishers will be very annoyed if your ad delays their website loading. 无论您从哪里提供服务,最好都超级快,因为当今您将与之竞争的广告服务器非常快,如果您的广告延迟了网站的加载,发布商会非常恼火。

Good luck - you have a lot of challenges if you want to pull this off, least of which will be paying for servers to accomplish it. 祝您好运-如果要实现这一目标,您将面临很多挑战,其中最少的一项将是为实现这一目标而付费。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM