Bug 13247

Summary: opacuserjs is not compatible with tracking's tools like Piwik
Product: Koha Reporter: Stéphane Delaune <stephane.delaune>
Component: TemplatesAssignee: Stéphane Delaune <stephane.delaune>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P3 CC: tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: proposed patch
new proposed patch
[SIGNED-OFF] Bug 13247 - Move opacuserjs at the end of opac-bottom.inc
[PASSED QA] Bug 13247 - Move opacuserjs at the end of opac-bottom.inc

Description Stéphane Delaune 2014-11-13 13:42:26 UTC
some tools needs to add javascript just before the </body> tag .This is particularly the case of statistical :
- Piwik (the page "http://developer.piwik.org/api-reference/tracking-javascript" indicates "copy and paste the JavaScript Tracking code into your pages, just before the </body> tag")

- Google Analytics (the page "https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingOverview?hl=fr" indicates "This tracking code snippet should be included in your site's pages so that it appears at the bottom of the page's HTML (or generated-HTML) structure, before the closing <body> tag.")

To use these tools with the syspref "opacuserjs", its use should be moved to the end of opac-bottom.inc
Comment 1 Stéphane Delaune 2014-11-13 13:55:03 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2014-11-13 14:22:29 UTC
Comment on attachment 33521 [details] [review]
proposed patch

Review of attachment 33521 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
@@ +238,5 @@
>  [% PROCESS jsinclude %]
>  
> +<script type="text/javascript">
> +    //<![CDATA[
> +    [% IF ( opacuserjs ) %][% opacuserjs %][% END %]

Wouldn't it make more sense to put the IF and END around the entire script? Why generate a hollow script section?
Comment 3 Owen Leonard 2014-11-13 14:58:09 UTC
(In reply to M. Tompsett from comment #2)

> Wouldn't it make more sense to put the IF and END around the entire script?
> Why generate a hollow script section?

I agree. Other than that I think this change will work.
Comment 4 Stéphane Delaune 2014-11-14 07:54:06 UTC Comment hidden (obsolete)
Comment 5 Owen Leonard 2014-11-14 17:23:53 UTC Comment hidden (obsolete)
Comment 6 Katrin Fischer 2014-11-16 09:44:54 UTC
Created attachment 33600 [details] [review]
[PASSED QA] Bug 13247 - Move opacuserjs at the end of opac-bottom.inc

This patch makes opacuserjs compatible with tracking tools like Piwik

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Small change to enable use of opacuserjs for statistical
tools like Piwik by moving it right above </body>.
Works as described.
Comment 7 Tomás Cohen Arazi 2014-11-21 23:34:24 UTC
Patch pushed to master.

Thanks Stephane!