Is it possible to test Google AutoAds in a demo or localhost environment? - adsense

Similar to this question, I would like to test Google Adsense in a page to see how it impacts layout and performance, etc. before go-live. I would like to do this on https://localhost and on a demo site. However, my customer is using AutoAds, with markup that looks like this:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-1234567890",
enable_page_level_ads: true,
google_adtest: "on" //This doesn't seem to work?
});
</script>
Is there a way to test AutoAds on localhost and non-production sites? Related, is there documentation for google_adtest?

Yes and no ... more like no :) I still recommend you try.
So basically Auto Ads don't run right away, because Google needs time to analyze not only ur site's content, but also structure.
So because localhost is not a public domain, google structure crawler can't see ur site... However I do see live google ads on my localhost ... the non-auto- ads... Regular fixed size ads.
Also, auto ads is not very profitable

Related

Facebook Using code from different domains

I am creating a widget in js that will be implemented across many websites,
Facebook requires me to give them "my domain" so they will know that I am verified.
The problem is that the widget will be used from many websites, and I am not going to manuly list all of those domains to Facebook.
How can I enable my app to work from those different websites using js only? (for the widget)
Thanks in advance.
Your widget will probably need to load its FB code within an iFrame that is hosted on your own domain. Then you'll need to use some cross-domain / cross-iframe JS hacks to get your system to communicate with the page that uses it. (Here's a good resource on doing that... http://softwareas.com/cross-domain-communication-with-iframes) This is definitely a pain, but it's the only way I can think of to do what you're trying to do. There may be some good JS libraries out there at this point to make this easier, but I'm not immediately aware of any.
The other option is to create a bunch of Facebook applications that each belong to a different domain. This would also bring some pain in terms of maintenance, but it would simplify the JS code you'd need to write quite a bit. This approach has some upside in terms of robustness -- if one of the sites using your widget goes rogue and gets the application banned for whatever reason, you other client sites won't be affected.
Facebook used to provide a "clone application" tool but just now I couldn't find it.
i use ajax for something similar. i ajax to a php page, and use the php sdk for all the requests. cross domain just fine.
EXAMPLE: should request most recent albums updated on facebook and display cover photo linked to the album on facebook.
<div id="pagealbums"></div>
<script>
function showAlbums(){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttpA=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttpA=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttpA.onreadystatechange=function()
{
if (xmlhttpA.readyState==4 && xmlhttpA.status==200)
{
document.getElementById("pagealbums").innerHTML=xmlhttpA.responseText;
}
};
xmlhttpA.open("GET","http://anotherfeed.com/feed.albums.php?pageid=facebook&type=list",true);
xmlhttpA.send();
}
showAlbums();
</script>

Facebook iFrame canvas app PHP sessions issue

I've been working on a problem for the last day and a half now and have still yet to find a solution.
When visitng my game on facebook (which is in facebook's iFrame) php sessions don't work. This is for IE and Safari. Chrome works fine.
I've already read all the posts on stack about this problem, which seems to be down to third party cookie security and needing interaction with the iFrame first. There was a workaround by making javascript post some form data to the iFrame first, but this seems to have been 'fixed' in the latest versions of the browsers very recently as this no longer works.
I even tried implementing a start page that would require them to click a link first (in the iFrame) to load another page which would then create the session. But even THAT doesn't work.
I'm also having trouble even loading new pages in the iFrame using javascript, which seems to always cause infinite loop refreshes.
And no, P3P headers do NOT solve it.
Does anyone have a solution to this problem? I can't be the only one with it, considering how many facebook apps exist!
I came across this problem using a client that had "Accept third party cookies" disabled. My solution was to force PHP to embed the session ID into the URI by putting this line at the start of each page:
ini_set('session.use_trans_sid', true);
As the URLs are in iframe within Facebook the SID is not seen in the top window.
For IE, you will need the P3P Headers set. Something like:
<?php header('P3P: CP="CAO PSA OUR"'); ?>
Safari blocks 3rd-party cookies by default. Currently, the only work-around that is working for me is to "pop-up" a new window to set the cookies. I have something like this:
<script type="text/javascript">
function safariFix(){
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1){
window.open('https://yourdomainname.com/safari.php', 'Safari Fix','width=100,height=100');
}
}
</script>
And safari.php will have this:
<?php
setcookie("safari_test", "1");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Safari Fix</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
window.close();
});
</script>
<body>
Since Safari does not accept third-party cookies by default, we are forced to open this window.
This window will automatically close once we have set the cookies.
</body>
</html>
PROBLEM: This won't work if users have "block pop-ups" enabled in Safari. If anyone has a better solution for this, inform me ;)

Error launching native application from web app - iOS - URL can't be shown

I'm running into a bit of trouble trying to call my native iOS application from my web app (apple-mobile-web-app-capable). Whenever I'm in Safari pressing the button to open my app with a custom url scheme, that works just fine.
However, when I've added it to the home screen I get stuck with the error: The URL can't be shown. Redirecting to http or https works fine but if I call mysupercustomurlscheme:// I get the error message above.
I've tried opening it by document.location.href, window.location, etc etc but nothing seems to do the trick and I've run out of ideas.
If anyone has got any ideas I'd be most grateful to hear them.
Thanks in advance!
Okay, here's a somewhat clumsy way to do it, but it works and might help some poor soul out there trying to achieve the same thing.
First, create a simple HTML link as, apparently, regular HTML links open in Mobile Safari instead of within the full screen view in the web app.
Link
In redirect.html you simply redirect the user with some simple javascript.
window.location = "mysupercustomurlscheme://"
And that's it! It's certainly not the best way to do it but it's 'fairly' seamless. That's what I came up with at least, if you have any other suggestions do let me know.
Hope this helps someone!
Just wanted to post an example of what Tobias is referencing. You need to host on your server and link to in emails, social media, etc. Simply substitute in your app's URI and your App Store link. Note that the iframe works on more browsers.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
window.onload = function() {
// Deep link to your app goes here
document.getElementById("l").src = "my_app://";
setTimeout(function() {
// Link to the App Store should go here -- only fires if deep link fails
window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8";
}, 500);
};
</script>
<iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
</body>
</html>
So, if the user has your app installed, the link with the URI will succeed and you will exist the browser before the script for redirecting to the App Store can be triggered. If the user does not have your app, the redirect succeeds (after a brief ugly error message). I am a developer at Branch and we use this, so feel free to reach out with questions in implementing.

Webapp for iphone switches from home screen to Safari when url parameters are used

I've developed a web app for the iPhone, and I have it bookmarked and added to my iPhone's home screen. I'm noticing a problem with it, though: it works as intended until I navigate to a page within the app that has a query string and parameters - for example, www.mywebapp.com/page02.html?param1=value&param2=value2 . When I go to a page with such a URL, iOS switches me from the embedded version of Safari to the main Safari app - it takes me out of my app. I don't know why this is happening.
What causes this and what can I do about it?
Many thanks to #BjornKaiser who provided the solution, here is a simple jQuery script that will handle this for you for all links.
Add this to the head section of your master ASP.Net page. Make sure you have jquery included:
<head>
<!-- Your reference to your jQuery library -->
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function() {
$('a').click(function() {
document.location = $(this).attr('href');
return false;
});
});
</script>
</head>
That's the way Apple designed it. If you need a multi-view Web App you need to implement the page switching logic in JavaScript. Everything else will cause the problem you described -> jumping to Safari.
I'm not sure what causes this, but this question about UIWebView issues has a solution for how to make some links open in the UIWebView page and some open in Mobile Safari, so I bet you could generalize from that to a solution to your problem.
I found the best solution: using client-side data storage. You can use JavaScript to store variables information into the variables localStorage and sessionStorage.
Look at these links:
O'Reilly client-side data storage tutorial and
Apple key-value client-side data storage tutorial for web apps

Fb.Share does not work

Till yesterday everything was working fine.
In my website's head there was
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
and links like
<a name="fb_share" share_url="http://mysite.com/url"></a>
were transformed to facebook share plugins.
But now there is a problem - i can't see count of shares in plugin. I sniffed requests a little and the error is:
fb_sharepro_render({"error_code":104,"error_msg":"Requires valid signature","request_args":[{"key":"v","value":"1.0"}
I did not change anything on website and problem still occurs. Any hints?
Edit (probably an answer):
This bug is described here: http://bugs.developers.facebook.net/show_bug.cgi?id=19471
Facebook team response:
Thanks for the report. We are looking into this.
We recommend to use the like button instead as we are going to deprecate the
share button soon. The like button provides you with the same functionality and
more ...
http://developers.facebook.com/docs/reference/plugins/like/
Also, works solution with request to http://graph.facebook.com/?ids=*.
For example, while issue is not fixed by facebook, you can use a little modified facebook share widget script, it use a graph.facebook.com instead of api.facebook.com/restserver.php.
You have to introduce access_token also as a parameter. Find what facebook says
GET /fql?q=SELECT+uid2+FROM+friend+WHERE+uid1=me()&access_token=...