How to manually update/generate correlator value with DFP - google-dfp

Trying to figure out how to generate a new correlator value for DFP without a whole page refresh or calling refresh() on all the ads on the page. There is a certain section of the site, that has certain sections of the page refresh via AJAX rather than completely reloading the page, but we would like to at these points, start using a new correlator value.
If there were a magic function like googletag.pubads().newCorrelator() that would be amazing, but I have not found anything.
I have tried the refresh() call which DOES generate a new correlator, but also refreshes all the ads on the page, which is not what I am looking to do.
Thanks!

This has been added to the GPT API recently.
You should be able to update correlator values with googletag.pubads().updateCorrelator();
Documentation: https://developers.google.com/doubleclick-gpt/reference#googletag.PubAdsService_updateCorrelator
Release notes: https://support.google.com/dfp_premium/answer/179039?hl=en

Related

How to find if web page got appended using chrome extension

I am new to chrome extension and I am trying to find whether page content got appended.
For E.g. in Facebook, we can see the content will appended automatically when the user scroll down the page.
I have the following code in background.js
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
alert("page is appending....");
});
The above code is expected to fire when the page got updated. But, I am seeing that it is getting called only for few times. Not always.
Or Am I making any mistake here ?
My requirement is, whenever the web page appended in facebook, I have to do get the page content and obtain few string from the same.
Thanks in advance.
Your onUpdated event is in the chrome.tabs namespace on purpose, it listens the updates of tab's general attributes like: the tab pinned, the favicon changed, the URL changed, see the documentation (also check the update() method). So this way is not workable. Instead listen the DOM tree change with DOMSubtreeModified event or MutationObserver.

Refresh Fb Comments Plugin

I'm trying to add a link to allow a user to refresh the Comments plugin on my page so they can see other posts by other people.
I want to do it without refreshing the full page.
There's a html5 player on the page playing audio, hence me not wanting to interrupt that player.
Currently I'm using the standard -
I've tried the jQuery method of giving the div an id and having a header script which counts to 10 and reloads the div widget, it seems to reload the widget, but it doesn't update the contents of the comments plugin to show other's posts, just ones you've added yourself. To see all the updates you have to refresh the page fully, which I don't want to do.
I'm trying to avoid iFrames because of the height issues and extra scroll bars, etc.
Any ideas would be appreciated
I'm not exactly sure what you're trying to do, but you can use the FB.XFBML.parse method to refresh plugins.
The only thing is that you'll need to first remove the old plugin from the dom, then add the new html5/xfbml placeholders (what you get from the comments plugin page when clicking "get code") and then use the FB.XFBML.parse method.

Facebook: Updating page tabs through Javascript SDK

I'm trying to update my tab on a series of pages on facebook. Due to the volume of pages I'm making batch calls to keep from being rate limited. The batch calls work fine.
That being said, I'm trying to Update a page tab by making the call as stated here. I have the adding functionality working fine, and it's operating as it should. I use the same method of getting and using tokens, and I know moreso that it's not an issue as I have offline access so they don't expire (I get them every page load, but in reality could just store them and not worry about it).
Both calls use the same page ID, app ID, and access token and the call is good. The Error I receive is that the tab does not exist on the page, yet when I go to https://graph.facebook.com/PAGE_ID/tabs/APP_ID my tab is there showing itself as on the page. When I post to that I get the error it's not there.
My question is this: Has anyone gotten this working yet and if so what did your call look like and am I missing something?
I would post code, but it's incredibly long and intertwined in my program so it would be difficult to extract it.
There's a slight issue with the page tabs API at the moment that means in some situations you need to prepend your app id in the call with app_ so /PAGE_ID/tabs/app_APP_ID, give this a try and see if it works.

Updating URL without refresh

I am iterating through data and generating parameterized URL's for links (to the same page, but with parameters) on a dashboard app. However, the way I'm doing it requires a page refresh when the user clicks the link.
Generating URL with a StringBuilder
Detailhtml.append("<a href=\"http://" + domain + "&service=" + count +"&day=" + day +"\"><img src=\"/info.jpg\" alt=\"Info\"/>");
Is there a way I can dynamically create GWT buttons, or trigger some javascript to add the parameters without a page refresh?
Any help would be great...
The page will refresh if any part of the URL before the fragment (#) changes. So if you go form foo.com#a to foo.com/?bar=baz#a, a page refresh will be triggered.
The best way to get around this is just to never change anything before the fragment. Change foo.com/?bar=baz to foo.com/#bar=baz (or some variant) and have your GWT app listen for History changes by calling History.addHistoryListener(...).
Then, when you hear a history change, parse the fragment in the URL and update your app accordingly.
Some libraries like gwt-platform provide a wrapper around this functionality and let you describe Places which will get triggered when the fragment updates to match them. If you end up doing a lot of complicated things with the fragment, it would be a good idea to look into places. But if you're just passing a few parameters around, you can get away with just listening for History changes.

Facebook app: Random quotes not refreshing on each page load

I have a Facebook app written in php that will display random quotes on your profile.
The box does not appear to update, it looks like it did when it was originally added.
I want to update the profile boxes on each page load (refresh), and not by a user action like clicking a link.
Any idea what is the problem and how to solve it?
This is how I did it for The Office Quotes application:
Put the random quote inside an image (many options to do this in PHP, I used the GD and Image Functions at http://us2.php.net/manual/en/ref.image.php to create a JPG containing the quote).
Accessing this dynamic image in a browser gives you a different random quote each time you refresh.
On the Facebook profile box or tab, simply link this image.
However, Facebook caches the image the first time it's loaded, so it never updates!
To force Facebook to update, you must update Facebook's image cache for the image's URL using the API function fbml.refreshImgSrc which is now accessed via the URL http://api.facebook.com/methods/fbml.refreshImgSrc and requires the access_token parameter like all other API requests. There was an announcement some time ago that this function was being deprecated, but the decision was reversed!
Setup the cache refresh code to run regularly. You can do this on a scheduled task (i.e. a cron job) or on each pageview in the application, or any other way you can think of that will cause the method to be run with the relative frequency the image will be requested by a user.
I also linked the image in the profile to a page in the app that would continually reload a new random image. Users generally would click to this page (which would refresh the image cache on each load) and they get the illusion that the image updates constantly.
Another illusion that I like even better is to add a 'Refresh' link in the profile box/tab that links to a script that refreshes the image cache and immediately returns to the user's profile, so that it actually appears to just be refreshing the profile box/tab.
Enjoy!
Profile content is cached by Facebook and does not connect to your server on every page load. This has always worked like this. No javascript runs on load/automatically, so you can't have a new quote displayed on page load.
What you can do is put a bunch of quotes in the profile content and us the fb:random tag to display a random quote on page load from the random option list. Periodically you can run a script to update the set of quotes in the user profile. If quotes are not unique to each user, you should use fb:ref handles so you just have to update the handle content, not each user's profile. Just put the ref handle in the user's profile.
I'm confused. Profiles boxes are all but gone. You shouldn't be developing anything for a profile box right now - it's just gonna disappear any day now anyway.
And even when profile boxes were still a suggested integration point, you couldn't update them in the way you are wanting to.