how to set PageTargeting() dynamically
DoubleClickProvider.defineSlot('/530209488/Parties_1', [300, 100], 'div-gpt-ad-1470051144620-0') .defineSlot('/530209488/Parties_2', [300, 100], 'div-gpt-ad-1470051144620-1') .defineSlot('/530209488/Parties_3', [300, 100], 'div-gpt-ad-1470051144620-2'); DoubleClickProvider.setPageTargeting('city',localStorage.getItem('DFTcity'));
on changing the localStorage city value, the pageTargeting is not changing dynamically . it is effecting after hard refreshing the page(this is due app.config() is re initializing at the time city value taking). How i can change pageTargeting from my controller.
Just changing the localStorage setting won't update unless you have some listener. As of now it's not possible to change page targeting during runtime, but I guess you could do something like
googletag.pubads().setTargeting('city', localStorage.getItem('DFTcity');
from inside your controller once the localStorage setting gets updated.
here is the my code
App.config(['DoubleClickProvider',function (DoubleClickProvider) { DoubleClickProvider.defineSlot('/value_1', [300, 100], 'div-gpt-ad-1470051144620-0') .defineSlot('/value_2', [300, 100], 'div-gpt-ad-1470051144620-1') .defineSlot('/value_3', [300, 100], 'div-gpt-ad-1470051144620-2'); DoubleClickProvider.setPageTargeting('city',localStorage.getItem('DFTcity')); }]); app.controller('myController',function($scope,$rootScope){ $scope.init = function(){ googletag.pubads().setTargeting('city', $rootScope.selectedCity); } $scope.init() });
i am getting this error in console "googletag.pubads is not a function"