How to change the hyperlink on the cookie banner?

How to change the hyperlink on the cookie banner?

Baris
Tourist
9 0 1

Hi there, the hyperlink on our Shopify cookie banner is wrong. If I click on "privacy policy" it sends me to the German web store but it should stay on the English web store.

 

Bildschirmfoto 2025-02-20 um 15.03.53.pngBildschirmfoto 2025-02-20 um 15.04.00.pngHow and where can I change this? See the screenshots

Replies 4 (4)

theycallmemakka
Shopify Partner
1796 436 465

Hi @Baris ,

 

I have written custom JS to update the URL. Please add the below script on the theme.liquid file just above </body>

 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the below code just above </body>

<script>
(function checkAndUpdateLink() {
    const targetSelector = 'a#shopify-pc__banner__body-policy-link';
    const checkInterval = 500; // Check every 500ms
    const maxAttempts = 20000 / checkInterval; // Stop after 15 seconds
    let attempts = 0;

    function updateLink() {
        const linkElement = document.querySelector(targetSelector);

        if (linkElement) {
            const baseUrl = window.location.origin;
            let newHref = '';

            if (baseUrl === 'https://gardenigloo.shop') {
                newHref = 'https://gardenigloo.shop/policies/privacy-policy';
            } else if (baseUrl === 'https://gardenigloo.fr') {
                newHref = 'https://gardenigloo.fr/policies/privacy-policy';
            }

            if (newHref && linkElement.href !== newHref) {
                linkElement.href = newHref;
            }
        } else if (attempts < maxAttempts) {
            attempts++;
            setTimeout(updateLink, checkInterval);
        }
    }

    updateLink();
})();
</script>

 

Note: Please take backup of the original file so that you can revert the changes.

 

If you need any help adding this code on the site, you can let me know.

 

If you require further help to optimize your store, please don’t hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!

 

Best Regards,
Makka

 

Support Me: Buy me a Coffee


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com

Baris
Tourist
9 0 1

Hi Makka, thank you for your efforts. We have activated the Shopify cookie banner and somewhere in the theme codes must be this wrong link which I want just to edit. I don`t want to add more codes in the theme because the other 2 stores (German and French) are working well. I could edit them via Translate & Adapt app. But I cannot find the "original code" for the English cookie which I am looking for. 

theycallmemakka
Shopify Partner
1796 436 465

Thank you for reaching out. Since you're using a paid theme, I don't have direct access to the code to pinpoint where the link needs to be updated. However, if you can provide more details or access, I'd be happy to guide you in the right direction.

Support Me: Buy me a Coffee


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com

Baris
Tourist
9 0 1

I have sent you an email