Jump to content

Search the Community

Showing results for tags 'adsense'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Found 4 results

  1. Adsense Mobile Ad Unit

    I am working to make my site work better with mobile browsers and I also wanted to place a floating ad along the bottom like I see on many sites. It would appear that Google changed their ad unit from a normal ad the site of a mobile screen to a completely different ad modem that is very code driven. They give you the option of either PHP or JSP but it isnt the easy to edit code they used. Plus instead of having the control of being able to place it somewhere on your page it seems to place it right at the top and I cant figure out a way around that. I placed the PHP code directly into the functions page and it just worked but again with no control by me. I would like to use a hook or something to better control its position. I tried CSS but the control holding the iframe has a randomly generated name so I cant really apply CSS to it. When I attempt to put Either the PHP or the JSP into a function to call as an "add_action" it gives me errors. Could anyone give me some idea of how to add this where I might have a little more control of its location or the best way to add it to pagelines customize. This is the PHP version: <?php $GLOBALS['google']['client']='ca-mb-pub-xxxxxxxxxxxxxx'; $GLOBALS['google']['https']=read_global('HTTPS'); $GLOBALS['google']['ip']=read_global('REMOTE_ADDR'); $GLOBALS['google']['markup']='xhtml'; $GLOBALS['google']['output']='xhtml'; $GLOBALS['google']['ref']=read_global('HTTP_REFERER'); $GLOBALS['google']['slotname']='6199803051'; $GLOBALS['google']['url']=read_global('HTTP_HOST') . read_global('REQUEST_URI'); $GLOBALS['google']['useragent']=read_global('HTTP_USER_AGENT'); $google_dt = time(); google_set_screen_res(); google_set_muid(); google_set_via_and_accept(); function read_global($var) { return isset($_SERVER[$var]) ? $_SERVER[$var]: ''; } function google_append_url(&$url, $param, $value) { $url .= '&' . $param . '=' . urlencode($value); } function google_append_globals(&$url, $param) { google_append_url($url, $param, $GLOBALS['google'][$param]); } function google_append_color(&$url, $param) { global $google_dt; $color_array = explode(',', $GLOBALS['google'][$param]); google_append_url($url, $param, $color_array[$google_dt % count($color_array)]); } function google_set_screen_res() { $screen_res = read_global('HTTP_UA_PIXELS'); if ($screen_res == '') { $screen_res = read_global('HTTP_X_UP_DEVCAP_SCREENPIXELS'); } if ($screen_res == '') { $screen_res = read_global('HTTP_X_JPHONE_DISPLAY'); } $res_array = preg_split('/[x,*]/', $screen_res); if (count($res_array) == 2) { $GLOBALS['google']['u_w']=$res_array[0]; $GLOBALS['google']['u_h']=$res_array[1]; } } function google_set_muid() { $muid = read_global('HTTP_X_DCMGUID'); if ($muid != '') { $GLOBALS['google']['muid']=$muid; return; } $muid = read_global('HTTP_X_UP_SUBNO'); if ($muid != '') { $GLOBALS['google']['muid']=$muid; return; } $muid = read_global('HTTP_X_JPHONE_UID'); if ($muid != '') { $GLOBALS['google']['muid']=$muid; return; } $muid = read_global('HTTP_X_EM_UID'); if ($muid != '') { $GLOBALS['google']['muid']=$muid; return; } } function google_set_via_and_accept() { $ua = read_global('HTTP_USER_AGENT'); if ($ua == '') { $GLOBALS['google']['via']=read_global('HTTP_VIA'); $GLOBALS['google']['accept']=read_global('HTTP_ACCEPT'); } } function google_get_ad_url() { $google_ad_url = 'http://pagead2.googlesyndication.com/pagead/ads?'; google_append_url($google_ad_url, 'dt', round(1000 * array_sum(explode(' ', microtime())))); foreach ($GLOBALS['google'] as $param => $value) { if (strpos($param, 'color_') === 0) { google_append_color($google_ad_url, $param); } else if (strpos($param, 'url') === 0) { $google_scheme = ($GLOBALS['google']['https'] == 'on') ? 'https://' : 'http://'; google_append_url($google_ad_url, $param, $google_scheme . $GLOBALS['google'][$param]); } else { google_append_globals($google_ad_url, $param); } } return $google_ad_url; } $google_ad_handle = @fopen(google_get_ad_url(), 'r'); if ($google_ad_handle) { while (!feof($google_ad_handle)) { echo fread($google_ad_handle, 8192); } fclose($google_ad_handle); } ?> This is the JSP version: <%@ page import="java.io.BufferedReader, java.io.InputStreamReader, java.io.IOException, java.io.UnsupportedEncodingException, java.net.URL, java.net.URLEncoder, java.util.ArrayList, java.util.List" %> <%! private static final String PAGEAD = "http://pagead2.googlesyndication.com/pagead/ads?"; private void googleAppendUrl(StringBuilder url, String param, String value) throws UnsupportedEncodingException { if (value != null) { String encodedValue = URLEncoder.encode(value, "UTF-8"); url.append("&").append(param).append("=").append(encodedValue); } } private void googleAppendColor(StringBuilder url, String param, String value, long random) { String[] colorArray = value.split(","); url.append("&").append(param).append("=").append( colorArray[(int)(random % colorArray.length)]); } private void googleAppendScreenRes(StringBuilder url, String uaPixels, String xUpDevcapScreenpixels, String xJphoneDisplay) { String screenRes = uaPixels; if (screenRes == null) { screenRes = xUpDevcapScreenpixels; } if (screenRes == null) { screenRes = xJphoneDisplay; } if (screenRes != null) { String[] resArray = screenRes.split("[x,*]"); if (resArray.length == 2) { url.append("&u_w=").append(resArray[0]); url.append("&u_h=").append(resArray[1]); } } } private void googleAppendMuid(StringBuilder url, List<String> muids) { for (String muid : muids) { if (muid != null) { url.append("&muid=").append(muid); return; } } } private void googleAppendViaAndAccept(StringBuilder url, String via, String accept) throws UnsupportedEncodingException { googleAppendUrl(url, "via", via); googleAppendUrl(url, "accept", accept); } %> <% long googleDt = System.currentTimeMillis(); StringBuilder googleAdUrlStr = new StringBuilder(PAGEAD); googleAdUrlStr.append("&client=ca-mb-pub-xxxxxxxxxxxxxx"); googleAdUrlStr.append("&dt=").append(googleDt); googleAppendUrl(googleAdUrlStr, "ip", request.getRemoteAddr()); googleAdUrlStr.append("&markup=xhtml"); googleAdUrlStr.append("&output=xhtml"); googleAppendUrl(googleAdUrlStr, "ref", request.getHeader("Referer")); String googleUrl = request.getRequestURL().toString(); if (request.getQueryString() != null) { googleUrl += "?" + request.getQueryString().toString(); } googleAdUrlStr.append("&slotname=6199803051"); googleAppendUrl(googleAdUrlStr, "url", googleUrl); String googleUserAgent = request.getHeader("User-Agent"); googleAppendUrl(googleAdUrlStr, "useragent", googleUserAgent); googleAppendScreenRes(googleAdUrlStr, request.getHeader("UA-pixels"), request.getHeader("x-up-devcap-screenpixels"), request.getHeader("x-jphone-display")); List<String> googleMuids = new ArrayList<String>(); googleMuids.add(request.getHeader("X-DCMGUID")); googleMuids.add(request.getHeader("X-UP-SUBNO")); googleMuids.add(request.getHeader("X-JPHONE_UID")); googleMuids.add(request.getHeader("X-EM-UID")); googleAppendMuid(googleAdUrlStr, googleMuids); if (googleUserAgent == null || googleUserAgent.length() == 0) { googleAppendViaAndAccept(googleAdUrlStr, request.getHeader("Via"), request.getHeader("Accept")); } try { URL googleAdUrl = new URL(googleAdUrlStr.toString()); BufferedReader reader = new BufferedReader( new InputStreamReader(googleAdUrl.openStream(), "AUTO_DETECT")); for (String line; (line = reader.readLine()) != null;) { out.println(line); } } catch (IOException e) {} %>
  2. Hi, I've been wondering why relevant ads haven't been displaying on my site. Well, according to AdSense, it's because they cannot crawl my pages. It's saying "http://kareemtaylor.com/" is a "page not found". This has only been true since the installation of Pagelines. Not sure what that does to the domain or accessibility of the domain. Any help would be greatly appreciated. All the best, Kareem
  3. On site front page I would like to add Adsense ads to morefoot or footer, but I always get some grey squares; I use the same code I wrote in Primary/Secondary Sidebar, that works. Where could it be the problem?
  4. Hello, I have just inserted an adsense banner using a custom function in my header section. My problem is that the branding section where my logo is links to my homepage and the span of the clickable area covers the full width of the header. Therefore when my adsense ad is clicked it just reloads my homepage. How can I either disable the homepage link altogether or make it so that it only happens when the logo of the website is clicked as opposed to clicking anywhere in the header? Thanks