--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/eyVo4XU04uk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Well, here is the first big problem. Adsense and Ajax based websites don't really play well. Adsense allows you to place up to three standard ad units in a page. But in a Single Page App only the first page load is a full load. Subsequently when the routes change new partials are loaded into the ng-view or ui-view. For adsense these routes/states are not different pages. As a result you can not put ads inside your partials. You can only put these ads outside ng-view or ui-view (may be in the sidebar or header).
Now the problem is that if you put the ads in the sidebar, header etc they never get refreshed. Because the new partials are loaded into a specific div and your ads are not present there. Here we need some kind of technique to refresh the ads because users who spend a lot of time in your website will keep seeing the same ads. So, the solution is using DoubleClick for Publishers. You can serve your adsense ads through DFP and refresh them in a certain interval.
If you already have an adsense account just use the same for DFP. Once you have logged into DFP, create a new ad unit. Be sure to check Maximize revenue of unsold and remnant inventory with AdSense checkbox. Fill the necessary fields, save the ad unit and click the button Generate Tags for getting the GPT tags. This is pretty simple and straightforward.
Once you use the GPT tags and see ads in your website you can put the following code in the run() function of your AngularJS module to refresh the ads:
$interval(function(){
if($window.googletag && $window.googletag.pubads){
$window.googletag.pubads().refresh();
}
},60000);window.googletag.pubads().refresh() refreshes all the ad units in the page. We combine it with $interval() to trigger the refresh in every 60s. You can also refresh the ads when a new partial is loaded. This can be done by subscribing to events like $routeChangeSuccess or $stateChangeSuccess.
Hi
Visit this group at https://groups.google.com/group/angular.