• Resolved Arnaud

    (@arnaudv33)


    Hello,

    I just installed tarteaucitron.js in order to be GDPR compliant and I’ve got on issue because even if I exclude it, it’s still not working. I used the official website to install it: https://opt-out.ferank.eu/en/install/.

    Here is what I added in functions.php (child theme):
    add_action( ‘wp_enqueue_scripts’, ‘tarteaucitron_load’ );
    function tarteaucitron_load() {
    wp_enqueue_script( ‘tarteaucitron’, ‘/tarteaucitron/tarteaucitron.js/tarteaucitron.js’ );
    }
    add_action( ‘wp_head’, ‘tarteaucitron_init’ );
    function tarteaucitron_init() {
    ?><script>
    tarteaucitron.init({
    “hashtag”: “#tarteaucitron”,
    “highPrivacy”: false,
    “orientation”: “top”,
    “adblocker”: false,
    “showAlertSmall”: true,
    “cookieslist”: true,
    “removeCredit”: false
    });
    </script><?php
    }

    add_action( ‘wp_footer’, ‘tarteaucitron_services’ );
    function tarteaucitron_services() {
    ?><script>
    tarteaucitron.user.analyticsUa = ‘XXXXXXXX’;
    tarteaucitron.user.analyticsMore = function () { ga(‘set’, ‘anonymizeIp’, true); };
    (tarteaucitron.job = tarteaucitron.job || []).push(‘gtag’);
    (tarteaucitron.job = tarteaucitron.job || []).push(‘youtube’);
    (tarteaucitron.job = tarteaucitron.job || []).push(‘recaptcha’);
    </script><?php
    }

    In the console, it’s displaying the error below:
    Uncaught ReferenceError: tarteaucitron is not defined.

    Could you please help me?

    • This topic was modified 7 years, 9 months ago by Arnaud.
Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    don’t know (yet), so some questions;

    -> how did you exclude it?
    -> can you share your sites URL or could I see this solution at work somewhere?

    frank

    Thread Starter Arnaud

    (@arnaudv33)

    I added this:

    tarteaucitron.js,tarteaucitron/tarteaucitron.js/tarteaucitron.js,tarteaucitron/tarteaucitron.js/lang/tarteaucitron.fr.js?v=20181023,/tarteaucitron/tarteaucitron.js,tarteaucitron/tarteaucitron.js/tarteaucitron.services.js?v=20181023,

    in Async Javascript Settings “Script Exclusion”. Unfortunately, I can’t share you any link at the moment because I’m working on an internal test environment.

    Which additionnal information do you need to help me more?

    • This reply was modified 7 years, 9 months ago by Arnaud.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I added this:

    tarteaucitron.js,tarteaucitron/tarteaucitron.js/tarteaucitron.js,tarteaucitron/tarteaucitron.js/lang/tarteaucitron.fr.js?v=20181023,/tarteaucitron/tarteaucitron.js,tarteaucitron/tarteaucitron.js/tarteaucitron.services.js?v=20181023,

    in Async Javascript Settings “Script Exclusion”.

    And when checking HTML source, can you confirm the tarteaucitron.js script does not have async of defer attributes?

    Which additionnal information do you need to help me more?

    well, ideally I can compare the script in a working and a non-working state and at least I’d need to see it working somewhere (not necessarily on your site).

    Thread Starter Arnaud

    (@arnaudv33)

    Frank,

    You can see it working on the official website: https://opt-out.ferank.eu/en/install/. Once you clicked on “Accept all”, you can find the “management panel” on the bottom right corner with a cookie logo.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    problem is that’s not a WordPress site, so not (entirely) representative of how it works in your context 🙂

    Thread Starter Arnaud

    (@arnaudv33)

    After a few research, I think this one is using it: https://www.webrankinfo.com/

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    looks that way, but they do have the defer flag and I don’t get a JS warning;

    <script type="text/javascript" src="https://www.webrankinfo.com/tarteaucitron/tarteaucitron.js" defer>

    but I don’t see any inline JS, which you do have …

    I think the main question now is;

    And when checking HTML source, can you confirm the tarteaucitron.js script does not have async of defer attributes?

    Thread Starter Arnaud

    (@arnaudv33)

    No there isn’t any async or defer attributes on this .js. The thing is this is working correctly when I disable autoptimize & async javascript but if I enable one of them it’s not working anymore. 🙁

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    ah, you’re trying both AO and AsyncJS, that kind of complicates things. Excluding tarteaucitron.js in both + making sure in AO “also aggregate inline JS” it not ticked _should_ work.

    if not to be able to continue I would need to see the resulting HTML, which you could copy/ paste in a pastebin paste maybe? and if you’d prefer to keep things private you could mail me at futtta-at-gmail-dot-com?

    Thread Starter Arnaud

    (@arnaudv33)

    Well, good news, we are close to solve the issue because it’s working when I only enable async plugin. So, the main problem isn’t async but AO but I’m not sure to understand the option I must disable, is it the one in the first tab called “home” or is it in the extra tab?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    but I’m not sure to understand the option I must disable, is it the one in the first tab called “home” or is it in the extra tab?

    it is the “home” (main) tab, but make sure you’ve clicked on the “show advanced settings”-button near the top-right corner 🙂

    Thread Starter Arnaud

    (@arnaudv33)

    Hi Frank,

    I deselected the option as you said and I saw in the console on error which say that it failed locating the tarteaucitron.css file so I added it to the CSS exclusion and now I can see these errors: https://pasteboard.co/HOa2Cqq.png

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    OK, apparently the tartaucitron-script has references to other files and those references are relative, so you’ll have to disable minification of JS that is excluded from aggregation.

    you can do that with this code snippet;

    add_filter('autoptimize_filter_js_minify_excluded','__return_false');

    Thread Starter Arnaud

    (@arnaudv33)

    It’s working, thank you very much! I only have this error left: https://pasteboard.co/HOawiz3.png.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    OK, you’ll probably have to add an exclusion for jquery.slick.min.js or slick.min.js or something similar (check your HTML source of a page with AO disabled by adding ?ao_noptimize=1 to the URL).

Viewing 15 replies - 1 through 15 (of 19 total)

The topic ‘tarteaucitron.js’ is closed to new replies.