Unfortunately the other answers all involve some kind of mess that will likely confuse people. Here's an attempt at a solid, modern solution that uses UNIVERSAL ANALYTICS (the new one) rather than "ga.js" (the old one, though there is an even older one urchin.js that no one uses anymore).
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'YOUR_UID_REPLACE_THIS', 'auto');
ga('require', 'displayfeatures');
ga('set', 'campaignSource', 'Facebook');
ga('set', 'campaignMedium', 'Social Instant Article');
ga('set', 'title', ia_document.title);
ga('send', 'pageview');
</script>
- YOUR_UID_REPLACE_THIS: Obviously put your personal GA code here.
- campaignSource: Shows up as "Source" in GA.
- campaignMedium: Shows up as "Medium" in GA.
- ia_document.title: This uses the FB javascript variable for title.
So far for me the title gets successfully replaced for me with this code.
I had some very confusing experiences trying to test this with the "REAL-TIME" report on Analytics, where multiple posts were showing up with the same title, but overall I think it's working.
- To test the 'title' field: REAL-TIME > BEHAVIOR
- To test the 'Source' and 'Media' fields: REAL-TIME > TRAFFIC SOURCES
To see the traffic under the Acquisitions section of GA, go to Acquisitions > Source / Medium where it will be listed along with other sources (including several different ones from facebook).
FLAW (shared with all the other solutions) - Unfortunately my solution doesn't get IA traffic to show in the Acquisitions > Social > Facebook report. Even worse, it doesn't even show in the Acquisitions > Social report. Sadly, it gets lost in Acquisitions > Other, and for most of us, will mean a totally messed-up Social report overall.
- The "Social" channel, like other channels, has a very precise set of
source / medium
values that it will filter into the different categories like Facebook.
- Clearly,
Facebook / Social Instant Article
isn't on that list.
- See This other StackOverflow post I made about this particular issue for more details. I will update my example here with whatever turns out to be the best practice.
Source for ia_document.title code: https://developers.facebook.com/docs/instant-articles/analytics