fb-instant-articles icon indicating copy to clipboard operation
fb-instant-articles copied to clipboard

Add support for Jetpack stats

Open kevinlisota opened this issue 8 years ago • 11 comments

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 avatar Aug 01 '16 16:08 kevinlisota

@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.

everton-rosario avatar Aug 01 '16 16:08 everton-rosario

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.

kevinlisota avatar Aug 01 '16 17:08 kevinlisota

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.

everton-rosario avatar Aug 01 '16 17:08 everton-rosario

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 avatar Aug 01 '16 18:08 kevinlisota

@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 avatar Aug 19 '16 20:08 everton-rosario

@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

menzow avatar Aug 24 '16 17:08 menzow

Any luck with this one?

dfroberg avatar Jan 06 '17 06:01 dfroberg

This also came up in Jetpack support, 3140036-t.

joendotcom avatar Apr 03 '17 11:04 joendotcom

and here 3145345-t

seejacobscott avatar Apr 04 '17 21:04 seejacobscott

Any update on this ?

goranefbl avatar Jun 28 '17 20:06 goranefbl

This came up on a Jetpack forum thread too.

StefMattana avatar Dec 20 '17 09:12 StefMattana

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.

github-actions[bot] avatar Oct 16 '22 03:10 github-actions[bot]