1

I'm trying to get google adsense working in my events feed on a website I'm working on, but can't seem to get it to work. The ad is wrapped inside of an angular ng-repeat object. You can see it live at sparkmyinterest.com.

Here's a working example Angular.js & Adsense

Here is my cade:

<div class="col-xs-12 col-md-6 col-lg-4" ng-repeat="event in events" ng-mouseover="showSocial(event)">
    <div class="thumbnail event-box" ng-show="event.is_ad">
      <div style="color: grey; text-align: center">
        Advertisement
      </div>
      <div style="margin-left: auto; margin-right: auto; margin-top: 100px; text-align: center">
        <div data-my-ad-sense>
          <!-- Google AdSense -->
          <script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
          <ins class="adsbygoogle"
               style="display:inline-block;width:200px;height:200px"
               data-ad-client="ca-pub-00000000000"
               data-ad-slot="0000000"></ins>
          <script>
              (adsbygoogle = window.adsbygoogle || []).push({});
          </script>
        </div>
      </div>
    </div>
  </div>

And in the controller I have:

sparkApp.directive('myAdSense', function() {
    return {
        restrict: 'A',
        transclude: true,
        replace: true,
        template: '<div ng-transclude></div>',
        link: function ($scope, element, attrs) {}
    }
});

Strangely, this seems to work every once in a while, but is not very consistent.

ALSO: Does anybody know how I could test whether ads are working on localhost? It's been pretty hard to debug this issue.

Thank you.

Community
  • 1
  • 1
Rob
  • 7,028
  • 15
  • 63
  • 95

0 Answers0