Anyone using collective.googleanalytics in production?


I'm testing c.googleanalytics on plone 5.2.2 (py2). I've managed to get it installed and authorized with my analytics profile and it works. But I'm having problems with the downloads plugin which throws an ExpressionError rendering

ExpressionError: $ must be doubled or followed by a simple path

I've read that this a TALES error so I started reworking the templates but I'm wondering if anyone else is using this plugin and it's just me having the problem.

No, I am not using this.

The problem is probably caused by the page templates / engine / chameleon changes in Zope 4.4 and higher. Some expressions no longer work. Something like ${view/something} where something also contains a dollar sign, may fail now.
Looking at this may indeed be the case. The Chameleon template engine cannot parse it, and I do not blame it: I have a hard time parsing it too. :wink:

Easiest may be to replace the template with something like:

<script type="text/javascript" tal:content="structure view/download_tag">

And then in the Python view code add a method download_tag which returns what currently is in the template.

Or maybe it works if you make the template like this:

<script type="text/javascript">
    jQuery(function($) {
        var extensions = <span tal:replace="view/file_extensions" />;
        var extensionsPattern = new RegExp('\\.((' + extensions.join(')|(') + '))$', 'g');
        $('body').delegate('a', 'click', function() {
            if ($(this).attr('href').match(extensionsPattern) ||  $(this).attr('href').match(/\/at_download\//g)) {
                _gaq.push(['_trackEvent', 'File', 'Download', $(this).attr('href')]);

But this is untested and it may be completely invalid markup.

Thanks @mauritsvanrees, I agree that the browser view option is the best approach

Plone Foundation Code of Conduct