CookieYes / TagManager installation and tracking code

Hello,

First, to do this, I used the online tutorial : https://fr.matomo.org/faq/tag-manager/using-cookieyes-consent-manager-cmp-with-matomo-tag-manager/?

I’m just interested in the cookie consent section. I do not require consent for tracking.

As a prerequisite, I inserted the tracking code in the head tag of my child theme. I checked that the code appeared correctly on all my pages.

Then I followed the steps in the document linked above : " Configure the CookieYes Tag" :

1/ I’ve created a new trigger called “Pageview CookieYes” (which is identical to the ‘Pageview’ trigger automatically created by matomo and linked to the “Matomo Analitycs” tag).
On this point, is it necessary to create the “PageViewCookieYes” trigger since it’s identical to the “Pageview” trigger?

2/ I’ve created a “CookieYes” tag to insert the CookieYes key, which is triggered by the “PageView CookieYes” trigger.

Then I followed the steps in the document concerning “Configure Matomo to apply consent to track with cookies” :

1/ I’ve checked the box in the “Matomo configuration” variable: require cookie consent

2/ I created a trigger named “DOMReady CookieYes”

3/ Then I linked the “Matomo Analytics” tag to the “PageviewCookieYes” trigger.
As a result, the “Matomo Analytics” tag is linked to the ‘PageView’ trigger (created automatically for tracking) and to the “PageviewCookieYes” trigger. My question: don’t these 2 triggers duplicate each other? don’t they have the same role? is it necessary to keep both?

4/ I created a new Tag “HTML Tag” nammed CookieYES CMP in which I copied the consent script (with the Head start position) linked to “DOMReady CookieYes” trigger.

5/ I published

When I perform the cookie deposit tests with (or without) consent, cookies are deposited (or not). When I revoke my consent to cookies, they are deleted. Everything seems to be working correctly.

However, when the cookies are deposited and I look at the source code of my page, the code inserted in the cookieYes CMP tag (the consent code below) does not appear in the code. is this normal? I understand from the linked document that the code should appear when cookies are deposited. Is this correct?

<script>
    var waitForTrackerCount = 0;
    function matomoWaitForTracker() {
        if (typeof _paq === 'undefined') {
            if (waitForTrackerCount < 40) {
                setTimeout(matomoWaitForTracker, 250);
                waitForTrackerCount++;
                return;
            }
        } else {
            document.addEventListener("cookieyes_consent_update", function (eventData) {
                const data = eventData.detail;
                consentSet(data);
            });
        }
    }
    function consentSet(data) {
        if (data.accepted.includes("analytics")) {
            _paq.push(['rememberCookieConsentGiven']);
            _paq.push(['setConsentGiven']);
        } else {
            _paq.push(['forgetCookieConsentGiven']);  
            _paq.push(['deleteCookies']);
        }
    }
    matomoWaitForTracker();
    </script>

Last question. Is this code correct in relation to my needs: to ask for consent for cookies only? to remember the choice? to deposit cookies or not according to the consent choice?

thank you for your feedback