# Cookie banner for Shopify and WordPress: how to add it

Updated 2 December 2026

Put the banner's script tag first in your site's head: in Shopify paste it into layout/theme.liquid; in WordPress install the Ruly plugin and paste your site ID, or paste the tag into the theme header. Then mark each tracker script so it waits for a yes; on WordPress the plugin holds known trackers for you. Trackers that are not marked or held keep running before the visitor chooses.

Canonical page: https://ruly.in/cookie-banner-shopify-wordpress

## Why an Indian store needs a cookie banner

The DPDP Act has no separate cookie rule. Where an analytics tag or ad pixel collects personal data for a use beyond running the site, the safe course is to ask first, with a clear notice and a no that is as easy as the yes (Section 6). Why that is, and which cookies need it, is at /blog/cookie-consent-dpdp.

Shopify has its own cookie banner, but its help page says it is set up for visitors in the UK and EEA when you sell there, and will not be active in other regions by default. A store that sells in India has to decide for itself what visitors in India see.

## Step 1: copy the script tag

The tag looks like this, with your own page name in place of "your-page": <script src="https://ruly.in/p/your-page/banner.js" async> followed by its closing script tag.

Copy the exact tag from the Cookie banner page in the Ruly app. The "Copy snippet" button copies it whole, closing tag included, so you never type it by hand.

## Step 2 on Shopify: paste it into theme.liquid

Shopify's help page gives the path: in your Shopify admin go to Online Store, click the horizontal menu icon next to your theme, then select Edit code. Shopify suggests you duplicate your theme first, so you have a copy to go back to.

Open the layout folder and then theme.liquid. Shopify's theme docs say this is the default layout file every theme must have, and that the content_for_header line must sit inside its head. Paste the Ruly tag as the first script inside the head, above the other scripts and above that line, then save.

Shopify also warns that if your code changes do not fit a theme update, the updated copy removes them. After you update or switch themes, open theme.liquid again and check the tag is still there.

## Step 2 on WordPress: the Ruly plugin, or the theme header

The easy way is Ruly's WordPress plugin. Sign up free, open the Cookie banner page in the Ruly app and click "Download the plugin". In WordPress go to Plugins, Add New Plugin, then Upload Plugin, pick the zip file, click Install Now and then Activate. These are the upload steps on WordPress's own Manage Plugins page.

Then go to Settings, Ruly Cookie Banner, paste your site ID and save. The site ID is the page name in your script tag ("your-page" in the example above), and the Cookie banner page shows it with a copy button. The plugin loads the banner in the head of every page. It can also add a Privacy link to your footer, which stays off until you tick it.

Save your site address on the Cookie banner page and turn the banner on, then run "Check my site" to see the banner is found. The plugin holds known trackers, like Google Analytics, Site Kit and Meta Pixel, until people say yes. Scripts it doesn't recognise keep running until you mark them. Use Check my site to see what's on your site. Scripts written straight into your theme files, or placed in a post, page builder block or shortcode, are not held either; add those by hand with data-ruly="analytics" or data-ruly="ads".

The other way is to paste the tag yourself. On a self-hosted WordPress site, go to Appearance, then Theme File Editor, and open your theme's header.php, the file WordPress uses to build the site's header. Paste the Ruly tag as the first script inside the head, then click Update File. Use one way, not both: if you switch to the plugin, remove the tag you pasted so the banner does not load twice.

WordPress's own page warns that the editor makes no backup copies and that a theme update wipes changes made this way. It suggests a child theme instead. If you are not comfortable editing files, or your theme has no header.php, the plugin is the simpler choice.

## Step 3: mark each tracker so it waits for a yes

The banner does not stop trackers on its own. You mark each one by hand, in the same place you pasted it. Change the tracker's opening tag from <script ...> to <script type="text/plain" data-ruly="analytics" ...> for analytics, or use data-ruly="ads" for ad pixels. If the tag says type="module", add data-ruly-type="module" too. Tracker code written inside the script tag works the same way.

A marked tracker does nothing until the visitor says yes to its category. A tracker you do not mark keeps running before a yes, whatever the visitor clicks.

- **Analytics:** Tags that count visits and clicks. Mark them data-ruly="analytics".
- **Ads:** Ad and retargeting pixels. Mark them data-ruly="ads".
- **Needed to run the site:** The cart, login and checkout. Leave these unmarked. They do not wait for a choice.

## What the banner cannot hold back

Ruly's banner can only hold back scripts you can see and mark in your theme. Some scripts load from places your theme does not control, and those can run before a yes.

Run "Check my site" in the Ruly app after you paste the tag. It shows each tracker it finds before and after a yes. For each one still running before a yes, turn it off if you do not need it, mark it if it sits in your theme, or change its own settings in the app or plugin that added it.

- **Shopify apps:** Apps you install can add their own scripts to your store, outside theme.liquid.
- **Shopify customer events and app pixels:** Shopify's help pages say app pixels come from marketing and data apps, and are managed in the Customer events section of your admin, not in your theme. Shopify says compliance with laws and consents for custom pixels is your responsibility.
- **WordPress plugins:** Analytics, ads and chat plugins can print their own scripts, which never pass through header.php.

## How Ruly does it

Ruly's cookie banner is on every plan. It shows Accept all and Reject all buttons of equal weight and a choice for each category, and it logs every choice with the time, the site and the banner version. Choices logged a month: Free 2,000, Ruly 10,000, Pro 50,000, Enterprise 50,000. One banner covers up to 3 site addresses.

On Shopify you paste one script tag; on WordPress the Ruly plugin adds it for you. On Shopify you mark your trackers by hand, as above; on WordPress the plugin holds known trackers and you mark the rest. "Check my site" in the app shows each tracker before and after a yes. Ruly has no Shopify app, so on Shopify the theme.liquid steps are how it works today.

Want to see what your site loads right now? The free check at /dpdp-website-check reads up to 5 pages of your site and lists the trackers it finds on each, and "Check my site" in the app reads up to 20. The free 2 minute check at /check gives you the rest of your to-do list.

## Sources

1. Shopify Help Center: Editing theme code: https://help.shopify.com/en/manual/online-store/themes/theme-structure/extend/edit-theme-code
2. Shopify developer docs: Layouts (theme.liquid): https://shopify.dev/docs/storefronts/themes/architecture/layouts
3. Shopify Help Center: Configuring customer privacy settings: https://help.shopify.com/en/manual/privacy-and-security/privacy/customer-privacy-settings/privacy-settings
4. Shopify Help Center: Pixels: https://help.shopify.com/en/manual/promoting-marketing/pixels
5. Shopify Help Center: Custom pixels: https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels
6. WordPress.org: Manage Plugins (Upload via WordPress Admin): https://wordpress.org/documentation/article/manage-plugins/#upload-via-wordpress-admin
7. WordPress.org: Appearance Theme File Editor Screen: https://wordpress.org/documentation/article/appearance-theme-file-editor-screen/
8. WordPress theme handbook: Template files: https://developer.wordpress.org/themes/classic-themes/basics/template-files/
9. DPDP Act Section 6: Consent: https://indiacode.ecourtsindia.com/digital-personal-data-protection-act-2023/section/6/

## Questions

### Is there a Ruly app for Shopify or a WordPress plugin?

There is a WordPress plugin: download it from the Cookie banner page in the Ruly app, upload it under Plugins, and paste your site ID. There is no Shopify app: on Shopify you paste one script tag into theme.liquid. On Shopify you mark your tracker scripts by hand so they wait for a yes; on WordPress the plugin holds known trackers and you mark the rest.

### Does the banner block every tracker automatically?

No. It holds back the trackers you mark with data-ruly="analytics" or data-ruly="ads" and, on WordPress, the known trackers the Ruly plugin holds. Other trackers, including scripts added by Shopify apps, app pixels or WordPress plugins the Ruly plugin doesn't recognise, can run before a yes. "Check my site" in the Ruly app shows which ones still do.

### Why paste it as the first script in the head?

So the banner loads before the trackers it has to hold back. A tracker placed above the tag can start before the banner is ready.

### Will a Shopify theme update remove the tag?

It can. Shopify's help page says code changes that do not fit a theme update are removed from the updated copy. After any theme update or switch, open theme.liquid and check the tag is still the first script in the head.

### Do I still need a privacy policy if I have a cookie banner?

Yes. The banner asks about cookies and trackers. The privacy policy tells people what personal data your store collects, why, and how to use their rights. What a Shopify store's policy needs is at /shopify-privacy-policy-india.

## Related

- [Free DPDP website check](https://ruly.in/dpdp-website-check)
- [Cookie consent under DPDP](https://ruly.in/blog/cookie-consent-dpdp)
- [Privacy policy for a Shopify store](https://ruly.in/shopify-privacy-policy-india)
- [Shopify store DPDP checklist](https://ruly.in/blog/shopify-store-dpdp)
- [DPDP for ecommerce and D2C](https://ruly.in/for/ecommerce-d2c)

---

Ruly: Get any business DPDP ready. Free 2 minute DPDP check at https://ruly.in/check. Contact hello@ruly.in. General information, not legal advice.
