开发者

Switch google adsense ad (mobile vs regular) based on user agent

开发者 https://www.devze.com 2023-02-11 04:11 出处:网络
I\'m optimizing a site so that on a mobile browser it only shows the mobile adsense ad, and on desktop it only shows the regular one. Problem is the google code leaves a white space where these ads ar

I'm optimizing a site so that on a mobile browser it only shows the mobile adsense ad, and on desktop it only shows the regular one. Problem is the google code leaves a white space where these ads are on 开发者_JS百科the page.

I want to know if there is an easy way to programmatically insert the ad (JS) based on the user agent.

Thanks.


It's very simple, see Masquerading Your Browser for details on how the User-Agent header works. See also the HTTP specification.

You haven't said which server side language you're using. In PHP you would look at the value of $_SERVER['HTTP_USER_AGENT'].

0

精彩评论

暂无评论...
验证码 换一张
取 消