ngDfp icon indicating copy to clipboard operation
ngDfp copied to clipboard

how to set PageTargeting() dynamically

Open krishnareddy226 opened this issue 8 years ago • 2 comments

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.

krishnareddy226 avatar Jun 09 '17 14:06 krishnareddy226

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.

ianmurrays avatar Jun 09 '17 14:06 ianmurrays

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"

krishnareddy226 avatar Jun 10 '17 06:06 krishnareddy226