How to implement google adsense in codigniter - google-ads-api

<script data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>`<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxx"></ins>

Store google adsense code in common view file and load it in required view page(s).
For example, save adsense code in adsense.php view file and call it in required files using below code
<?php $this->load->view('adsense'); ?>

Related

Where does it find the domain?

I am trying to load image files to my server. To do that I found this code as part of an ajax-example:
<!DOCTYPE html>
<html>
<head>
<title> Ajax JavaScript File Upload Example </title>
</head>
<body>
<!-- HTML5 Input Form Elements -->
<input id="fileupload" type="file" name="fileupload" />
<button id="upload-button" onclick="uploadFile()"> Upload </button>
<!-- Ajax JavaScript File Upload Logic -->
<script>
async function uploadFile() {
let formData = new FormData();
formData.append("file", fileupload.files[0]);
await fetch('/upload.php', {
method: "POST",
body: formData
});
alert('The file has been uploaded successfully.');
}
</script>
</body>
</html>
As I understand it, await fetch('/upload.php', tries to start a program named upload.php on the receiver, my server.
Aren't there supposed to be a domain-name? I mean, where is the upload-
file placed? This will only work if the user is also the owner of the domain, right?
Also, assume my program is on "https://DontTouchThis.com/uploads/", a subdirectory. Even users with this domain will not be able to start it.
I am confused.

Google Tag Assistant asks feed ID

I was asked to upgrade an existing site from using the old remarketing tracking code that looked like this:
<script type="text/javascript">
var google_conversion_id = 12345;
var google_custom_params = window.google_tag_params; // this is empty
var google_remarketing_only = true;
</script>
<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/12345/?value=0&guid=ON&script=0"/>
</div>
</noscript>
to another method that looks like this:
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-12345"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', 'AW-12345');
</script>
because it is asynchronous and should not block page loading. But the Google Tag Assistant extension that validates that tracking is set up correctly asks me to enter a "feed ID" when using the newer (gtag.js based) method. Previously it was showing Remarketing Tag as green.
Why is it needed now and not with the old code? I asked someone who has access to the AdWords account and they don't have the feed ID (or can't find it...).
I verified that the request to googleads.g.doubleclick.net/pagead/viewthroughconversion/ is sent though devtools as described in Verifiction using browser based developer tools:
https://developers.google.com/adwords-remarketing-tag/verification
Is my configuration correct?
That feed ID is related to dynamic remarketing campaigns. If you aren't running a dynamic campaign, then the feed ID shouldn't matter.
That field to enter a feed ID is there to help you with validating that your feed is working correctly.
Here is a quick video that might help clear up your questions. https://www.youtube.com/watch?v=QuOUNIFo0aQ

Why did not show toastr in my web application?

I'm beginner in asp.net mvc and want to use toast notification to show any message to user,read this tutorial and write this code in my view page:
<input type="submit" class="btn btn-primary" value="مشاهده" onclick="behzad()">
and this java script:
<script type="text/javascript">
function behzad() {
//alert("ok");
toastr.info('Hi Mahedee, This information for you.')
toastr.success('Are you the six fingered man?', 'Inigo Montoya');
}
</script>
but press the submit button i can see notification,how can i solve that problem?
and add this link to my view page:
<link href="~/Content/toastr.css" rel="stylesheet" />
<script src="~/Scripts/toastr.js"></script>
Did You follow these steps ??
bower install toastr
Link to toastr.css
Link to toastr.js
toastr.info('Are you the 6 fingered man?')
I Created this plunkr check the order of the scripts that are being loaded and check you are doing the same .. Thank you
enter code here http://plnkr.co/edit/CMkR8Ud7DOCnJCsGofvL?p=preview
toaster is using jQuery,
make sure you are importing jQuery before importing toaster

Google Mobile Ads SDK App Events with Click Tracking

We are displaying some ads in our iOS & Android applications using the Google Mobile Ads SDK. We need some parameters to make a web service call when the user clicks on the Ad and we get them using the GADAppEventDelegate, and after the web service call we present a custom screen. (so we don't want to redirect the user to a Web Page). The problem is that the Clicks are not tracked and we believe that Ad Creative might not be configured right.
<html><body leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<html>
<head>
<script src="http://media.admob.com/api/v1/google_mobile_app_ads.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function fireEvent() {
admob.events.dispatchAppEvent("query_string", "ad_origin_key=USPS2013_iPhone_Upgraded_320x50&k_key=&acid_key=719768856&ad_image_url_key=http://USPS2013_iphone_320x50");
}
</script>
</head>
<body>
<img src="http://pagead2.googlesyndication.com/pagead/imgad?id=CICAgIDQ59KwChABGAEyCKGNWPM-wPBl" width="320" height="50" border="0" onclick="fireEvent()"/>
</body>
</html></body></html>
I believe that in order not to be redirected to a Web Page we should make an AJAX request in fireEvent() function, something like $.get("%%CLICK_URL_UNESC%%www.example.com/ads/landingpage"); but the browser doesn't allow AJAX request to a server different of the original request server.
So how could we solve this issue, track the clicks and not navigate to a new web page?
Thanks
Hello i think this answer is a bit late but the code you quoted actually works!!
Inside your head tag of HTML of the creative
<script src="http://media.admob.com/api/v1/google_mobile_app_ads.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
// Send an event when ad loads.
// admob.events.dispatchAppEvent("adId", "1");
// handle your click with onClick="handleClick()"
handleClick = function() {
admob.log("click ad: call handleClick()"); // call a log to XCode console for debug
// Send an event when ad is clicked.
admob.events.dispatchAppEvent("eventName", "params"); //{action}|{action params}...
//magic goes here
//i think the click measure through this url
//and use jQuery get that send get method without callbacks
$.get("%%CLICK_URL_UNESC%%")
};
</script>
You have to wait a while like 30 mins then you will see the click stats in your DFP console.

Cakephp 2.0 implementing jquery UI

Okay so I am using cake PHP 2.0..just started using it so I am a total noob. I want to use dialog boxes to show some messages for an application so I am able to include the necessary javascript files and css for the jquery UI.
But when I define the function, It doesnot work instead when i look at the source code the script block in which i define the function looks incomplete as the closing tag '' is not highlighted. i hope i am making sense. here is the code snippet:
<script>
$(function() {
$( "#dialog" ).dialog();
});
</script>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
in 'index.ctp'.
I am certain that the js source files are loaded correctly
I picked it up from the jqueryUi site. I would be really grateful if some on could help me get started with writing javascript in cakePHP2.0. Thanks a ton
You should consider using cake's block or Element "mini-views." for that I'd use an element.
put something like this in app/view/Elements/loginDialog.ctp. I'll explain where the variable is decalred in the next section.
<div id="dialog" title="Basic dialog">
<?php echo $this->Form->create($ModelName); ?>
<?php
$this->Form->input('username');
$this->Form->input('password');
?>
<?php $this->Form->end('Login'); ?>
</div>
In your app/View/ControllerName/action_name.ctp, include something like this. Note that i'm able to pass in variables (Like the one that i used for the 1st Form parameter).
//in the view file
echo $this->element('loginDialog', array('ModelName'=>'User'));
Lastly you'll need to add the js. You could put this in your app/View/Layout/default.ctp. let's just say for instance you have a login link inside your navigation that you want to trigger this dialog:
<script>
$(document).ready(function(){
$("#loginNavLink").on("click", function(event){
$('#dialog').dialog();
});
})
</script>
Hope this helps!

Resources