Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set PageTargeting() dynamically #53

Open
krishnareddy226 opened this issue Jun 9, 2017 · 2 comments
Open

how to set PageTargeting() dynamically #53

krishnareddy226 opened this issue Jun 9, 2017 · 2 comments

Comments

@krishnareddy226
Copy link

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.

@ianmurrays
Copy link
Owner

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.

@krishnareddy226
Copy link
Author

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants