fb-instant-articles
fb-instant-articles copied to clipboard
Add support for Jetpack stats
Since FB IA supports both javascript and HTML analytics trackers, we should be able to add in the Jetpack stats javascript for sites that use Jetpack stats.
It looks like the Jetpack stats script is built dynamically for every page so that it contains the post ID, so we'd have to use the Jetpack function to output an op-tracker element.
@kevinlisota thanks for your contribution raising this other case.
Please, can you share here more info about this transformation problem?
We need you to click in the link "[Toggle debug information]" in the "Instant Articles" meta-box and then copy and past the both editor's text: "Source Markup" and "Transformed Markup"
With this info we can set some custom transformation rules for you to work around while we still dont have it released.
Your contributions makes Facebook Instant Articles great! Please join our group @ Facebook: https://web.facebook.com/groups/629655867187397/ There we have releases, announcements, events and all exchange between all Open Source tools regarding Instant Articles.
Analytics tracker scripts are currently added manually in the IA settings dialog, so they don't interact with the transformed markup or meta box in an article. The Jetpack stats script is not part of the article content, so a transformation rule isn't going to help.
What I'm suggesting is that if Jetpack stats is active on a site, then include the Jetpack stats tracking script in the op-tracker block sent to IA. This needs to be dynamically-generated because Jetpack stats is looking for a post ID in the tracker.
This should be possible by grabbing the script generated by Jetpack and dropping it in where the manually added scripts are inserts in the IA.
One option could be a checkbox in settings that says "include Jetpack tracking script" or some such thing, though unsure why anyone using Jetpack stats wouldn't want IA tracking as well.
You are saying that jetpack doesn't include the <script>
tag to the web markup by default?
Because, if it is included by default, our transformer will be able to transform it and append to the IA markup right before submitting to Facebook.
Jetpack stats script is inserted in wp-footer, not the post content, like many other analytics scripts. wp-footer content is not part of the IA transformation scripts, which is why your plugin has an options box to enter these scripts manually. Those are inserted as op-tracker elements when your plugin generates an IA.
I'm requesting that the plugin grab the dynamically-generated Jetpack stats tracker script and append it to the manually-entered analytics scripts as an op-tracker element before submitting the IA to FB.
@kevinlisota Sorry for the long time to get back to this issue. We were under water to get the next version of SDK and the WordPress plugin version 3.1.0 released.
Do you know what is the correct hook/filter that jetpack stats have the
Do you have some HTML code sample, so we can check if we can apply some transformation rule in a way we can select the correct <script>
block tag?
Closing until we get the code sample snippets. Will reopen when informed.
Thanks for using Instant Articles.
@everton-rosario you can find all code related to injecting the statistics script here: Plugin: https://wordpress.org/plugins/jetpack/stats/
File:
wp-content/plugins/jetpack/modules/stats.php
hook on line 122
Any luck with this one?
This also came up in Jetpack support, 3140036-t.
and here 3145345-t
Any update on this ?
This came up on a Jetpack forum thread too.
This issue has been marked stale because it has been open for 30 days with no activity. If there is no activity within 7 days, it will be closed. This is an automation to keep issues manageable and actionable and is not a comment on the quality of this issue nor on the work done so far. Closed issues are still valuable to the project and are available to be searched.