Google Admob in Webview on a PHP app using Javascript - javascript

I found the following way to add Google Admob ad on my webview app. I just want to know if this is an authentic way to do it and if it can get my account suspended or not. That's because the code looks hacky type. Normally we do this with Admob SDKs for Android app but the problem is that with that method the ad always appears at the bottom of the website's footer. Instead, I want my ads to be displayed inside my website at particular ad spots that I have created. Upon searching a lot I found some Youtube videos that demonstrates how to integrate admob ads on the webpage using the following javascript code. This code as test ad unit id with it. I created a test.php and placed this javascript code in it. Then I run the app in my webview and open test.php page and the test banner ad is successfully displayed.
Here is the script:
<script>
var pubid = '3940256099942544';
var s1 = '6300978111';
var pn1 = 'com.myappname.app';
var _0x6717=["\x68\x74\x74\x70\x73\x3A\x2F\x2F\x67\x6F\x6F\x67\x6C\x65\x61\x64\x73\x2E\x67\x2E\x64\x6F\x75\x62\x6C\x65\x63\x6C\x69\x63\x6B\x2E\x6E\x65\x74\x2F\x6D\x61\x64\x73\x2F\x67\x6D\x61\x3F\x70\x72\x65\x71\x73\x3D\x30\x26\x75\x5F\x73\x64\x3D\x31\x2E\x35\x26\x75\x5F\x77\x3D\x33\x32\x30\x26\x6D\x73\x69\x64\x3D","\x26\x63\x61\x70\x3D\x61\x26\x6A\x73\x3D\x61\x66\x6D\x61\x2D\x73\x64\x6B\x2D\x61\x2D\x76\x33\x2E\x33\x2E\x30\x26\x74\x6F\x61\x72\x3D\x30\x26\x69\x73\x75\x3D\x57\x25\x32\x37\x2B\x4D\x61\x74\x68\x2E\x66\x6C\x6F\x6F\x72\x25\x32\x38\x4D\x61\x74\x68\x2E\x72\x61\x6E\x64\x6F\x6D\x25\x32\x38\x25\x32\x39\x2A\x39\x25\x32\x39\x2B\x25\x32\x37\x45\x45\x41\x42\x42\x38\x45\x45\x25\x32\x37\x2B\x4D\x61\x74\x68\x2E\x66\x6C\x6F\x6F\x72\x25\x32\x38\x4D\x61\x74\x68\x2E\x72\x61\x6E\x64\x6F\x6D\x25\x32\x38\x25\x32\x39\x2A\x39\x39\x25\x32\x39\x2B\x25\x32\x37\x43\x32\x42\x45\x37\x37\x30\x42\x36\x38\x34\x44\x25\x32\x37\x2B\x4D\x61\x74\x68\x2E\x66\x6C\x6F\x6F\x72\x25\x32\x38\x4D\x61\x74\x68\x2E\x72\x61\x6E\x64\x6F\x6D\x25\x32\x38\x25\x32\x39\x2A\x39\x39\x39\x39\x39\x25\x32\x39\x2B\x25\x32\x37\x45\x43\x42\x26\x63\x69\x70\x61\x3D\x30\x26\x66\x6F\x72\x6D\x61\x74\x3D\x33\x32\x30\x78\x35\x30\x5F\x6D\x62\x26\x6E\x65\x74\x3D\x77\x69\x26\x61\x70\x70\x5F\x6E\x61\x6D\x65\x3D\x31\x2E\x61\x6E\x64\x72\x6F\x69\x64\x2E","\x26\x68\x6C\x3D\x65\x6E\x26\x75\x5F\x68\x3D\x25\x32\x37\x2B\x4D\x61\x74\x68\x2E\x66\x6C\x6F\x6F\x72\x25\x32\x38\x4D\x61\x74\x68\x2E\x72\x61\x6E\x64\x6F\x6D\x25\x32\x38\x25\x32\x39\x2A\x39\x39\x39\x25\x32\x39\x2B\x25\x32\x37\x26\x63\x61\x72\x72\x69\x65\x72\x3D\x25\x32\x37\x2B\x4D\x61\x74\x68\x2E\x66\x6C\x6F\x6F\x72\x25\x32\x38\x4D\x61\x74\x68\x2E\x72\x61\x6E\x64\x6F\x6D\x25\x32\x38\x25\x32\x39\x2A\x39\x39\x39\x39\x39\x39\x25\x32\x39\x2B\x25\x32\x37\x26\x70\x74\x69\x6D\x65\x3D\x30\x26\x75\x5F\x61\x75\x64\x69\x6F\x3D\x34\x26\x75\x5F\x73\x6F\x3D\x70\x26\x6F\x75\x74\x70\x75\x74\x3D\x68\x74\x6D\x6C\x26\x72\x65\x67\x69\x6F\x6E\x3D\x6D\x6F\x62\x69\x6C\x65\x5F\x61\x70\x70\x26\x75\x5F\x74\x7A\x3D\x2D\x25\x32\x37\x2B\x4D\x61\x74\x68\x2E\x66\x6C\x6F\x6F\x72\x25\x32\x38\x4D\x61\x74\x68\x2E\x72\x61\x6E\x64\x6F\x6D\x25\x32\x38\x25\x32\x39\x2A\x39\x39\x39\x25\x32\x39\x2B\x25\x32\x37\x26\x63\x6C\x69\x65\x6E\x74\x5F\x73\x64\x6B\x3D\x31\x26\x65\x78\x3D\x31\x26\x63\x6C\x69\x65\x6E\x74\x3D\x63\x61\x2D\x61\x70\x70\x2D\x70\x75\x62\x2D","\x26\x73\x6C\x6F\x74\x6E\x61\x6D\x65\x3D","\x26\x63\x61\x70\x73\x3D\x69\x6E\x6C\x69\x6E\x65\x56\x69\x64\x65\x6F\x5F\x69\x6E\x74\x65\x72\x61\x63\x74\x69\x76\x65\x56\x69\x64\x65\x6F\x5F\x6D\x72\x61\x69\x64\x31\x5F\x63\x6C\x69\x63\x6B\x54\x72\x61\x63\x6B\x69\x6E\x67\x5F\x73\x64\x6B\x41\x64\x6D\x6F\x62\x41\x70\x69\x46\x6F\x72\x41\x64\x73\x26\x6A\x73\x76\x3D\x31\x38\x22\x20\x68\x65\x69\x67\x68\x74\x3D\x22\x35\x35\x22\x20\x77\x69\x64\x74\x68\x3D\x22\x33\x32\x35\x22\x20\x66\x72\x61\x6D\x65\x62\x6F\x72\x64\x65\x72\x3D\x22\x30\x22\x20\x73\x63\x72\x6F\x6C\x6C\x69\x6E\x67\x3D\x22\x6E\x6F\x22\x20\x77\x69\x64\x74\x68\x3D\x22\x30\x22\x20\x68\x65\x69\x67\x68\x74\x3D\x22\x30\x22\x20\x6D\x61\x72\x67\x69\x6E\x77\x69\x64\x74\x68\x3D\x22\x30\x22\x20\x6D\x61\x72\x67\x69\x6E\x68\x65\x69\x67\x68\x74\x3D\x22\x30\x22\x20"];var src1=_0x6717[0]+ pn1+ _0x6717[1]+ pn1+ _0x6717[2]+ pubid+ _0x6717[3]+ s1+ _0x6717[4]
var _0x28f9=["\x3C\x68\x32\x20\x61\x6C\x69\x67\x6E\x3D\x22\x63\x65\x6E\x74\x65\x72\x22\x3E\x3C\x69\x66\x72\x61\x6D\x65\x20\x73\x72\x63\x3D\x22","\x2F\x3E\x3C\x2F\x69\x66\x72\x61\x6D\x65\x3E\x3C\x2F\x68\x31\x3E","\x77\x72\x69\x74\x65"];document[_0x28f9[2]](_0x28f9[0]+ src1+ _0x28f9[1])
</script>
Result in webview:
Also, can I use Google Adsense instead if I want to in my PHP website that opens in Webview?

Related

Google Apps Script - Autofill TextBox on another web page

I've to fill a texbox in an external website with a google app script based on google sheets. Is it possible?
For exemple I've to fill the textbox named "textbox1" in the website www.website.com,
To open the website the code is :
function myFunction() {
var js = "<script>window.open('www.website.com','_blank', 'width=800, height=600'); \
google.script.host.close(); ;</script>";
var html = HtmlService.createHtmlOutput(js);
SpreadsheetApp.getUi().showModalDialog(html, 'Now loading.');
}
normaly the code would be
document.getElementByName("textBox1").setAttribute("value","something")
but it doesn't work with google app script. Can you help me to understand how it works?
More Informations :
In my situation I have to click on a button on google sheets which will open a web page (not google suite) and automatically fill out a form (of course I know the names of the fields in advance as well as the data to put). My problem is therefore to modify an HTML page via an app script.
On Excel it was possible to do this with the InternetExplorer package which includes HTMLDocument for example.
Thanks a lot in advance !

Google AdSense testing code not displaying test ads on my live website

I am trying to implement exactly what was given from Google on what I should be implementing - https://support.google.com/admanager/answer/4599514?hl=en
I cannot seem to figure out why not a single test ad is rendering on my test page. My website is currently going through the approval process (Getting your site ready to show ads) and is not approved yet but in the criteria Google wants you to place all the code on the pages that you want ads displayed on. I simply won't place dynamic generated ads on my page if I have no idea how they look beforehand. I have also tried the fixed size ads and they do not show up when the attribute "test" is added in to the code.
Here is my code below:
<html>
<head>
<script async custom-element="amp-auto-ads"
src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
</script>
</head>
<body>
<h2>AdSense ad 2</h2>
<amp-auto-ads type="adsense" data-ad-client="MYID" google_adtest = on;></amp-auto-ads>
</body>
</html>
Edit 1: For awareness... I check the network files being requested when the page loads and I get a 200 for that amp-auto-ads. It loads in roughly 16.7KB of data
I know I probably should have just added a comment and the situation might be very different in your case. But for me, the ads showed up on my Safari but not Chrome, because I have AdBlocker on Chrome extension. Just disable that, and my ads show up again.

Javascript code for changing browser's tab title not working

For some reason, I can't find the problem or issue why I cannot use simple javascript code to update browser's tab text.
I'm doing a Shopify Application using Rails, which will be embedded and iframed to shopify.
I have a simple function to update tab title.
ex.
// jquery lib is loaded already....
$(function){ // i tried window on load as well
document.title = 'Sample';
}
But running it in browser's console has no problem.
No error shows in console, but not working... confusing...
I tried to make simple html file and it works there, only having issue when i put the code in my rails app, that being iframed in Shopify.
Any idea out there?

Using google adsense with React + React Router

I'm trying to integrate Google Adsense into my React site and am running into an issue. To get ads on my pages, I've included this script tag into the head of my html file:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
The ads are wrapped in a simple component that looks like this:
export default class GoogleAdSense extends Component {
componentDidMount() {
(window.adsbygoogle = window.adsbygoogle || []).push({});
}
render() {
const {
showAd,
className,
slot,
format,
} = this.props;
return (
<div className="GoogleAdSense">
<ins
className={ `adsbygoogle ${className}` }
style={{ display: 'block' }}
data-ad-client="ca-pub-7104738102834759"
data-ad-slot={slot}
data-ad-format={format}
>
</ins>
</div>
);
}
}
Which is rendered by other components like this:
<GoogleAdSense
slot="3461840703"
className="QuestionGoogleAd"
format="auto"
/>
This method was pulled from this article
Using the above implementation, ads load correctly on the page. The problem arises when users navigate to other pages. Since I'm using react router, the head doesn't update (with the exception of some react-helmet title changes) and the Adsense script doesn't reload. This makes Adsense think that it's on the same page as indicated by the Adsense pageview numbers I'm getting and the Adsense docs here:
Separate JavaScript code: AdSense counts a page view when the AdSense ad code is executed by a user's browser.
This is further evidenced by the fact that when I inspect the Adsense HTTP requests, I can see that there is a prev_fmts param that remembers the previous ads requested:
The problem is that after about 12-16 ads show up (2 per page, so maximum 8 page views), Adsense returns an empty html document with a 400 error for every subsequent ad request:
If I manually refresh the page by hitting cmd-r, the ads load correctly once again, but only for the next few pageviews. I tried removing the script I mentioned earlier and reinserting it into the head on each page change since that would (in theory) rerun the ad code and trigger a new Adsense pageview, but that didn't work. The main point of this site is to be able to show ads to generate a stable revenue stream and if I can't show ads on all of my pageviews (I'm averaging about 20 per user right now) using React, I'm going to have to reimplement the whole site, which I REALLY don't want to do. Has anyone else experienced this and found a solution?
You can use googletags to manage your adsense displays instead.
https://www.google.com/analytics/tag-manager/
They have functions to refresh the ads on a page https://support.google.com/dfp_sb/answer/2694377?visit_id=1-636301421618198678-920866889&rd=1 which will work for client side apps
You can use prepared react components for google publisher tag

How to use adsense after some time of page load

I've created a little social networking website which is working fine,
but in wall page google ads is not showing,
its showing and working fine in other pages
but in wall page not showing because the page content is showing with js
So i think there's a problem of keywords and description issue
i just want to know how to use google ads after sometime
i try
function show(){
//My Adsense Code But Still Not Working
}
setTimeout('show()',5000);
If you're making serious money with adsense, Google will give you access to premium ads including a very customizable api. If you got there you can format the ads in very different ways and supply the keywords you would like to be used.

Categories

Resources