Install cookie widget
This guide is designed to help customers install our cookie widget on their Shopify based website. Follow these few simple steps to get up and running quickly.

Before you start:

Before following these steps, please be sure that you have:
Check step 1 - 4 in the Get Started with Legal Monster guide to creating all of the above.

Step 1: Code snippet

To install your widget, you'll need your cookie widget code snippet.
The code snippet is the text in the text area at the bottom right.
To find your code snippet, go to the Legal Monster dashboard and select "Widgets" in the side menu. Click on the cookie widget you previously created and copy the code.
It will look like this:
!function(){var i,e,t,||[];if(s.SNIPPET_VERSION="3.0.0",i="",!s.__VERSION__)if(s.invoked)window.console&&"legal.js: The initialisation snippet is included more than once on this page, and does not need to be.");else{for(s.invoked=!0,s.methods=["cookieConsent","document","ensureConsent","handleWidget","signup","user"],s.factory=function(t){return function(){var;return e.unshift(t),s.push(e),s}},e=0;e<s.methods.length;e++)t=s.methods[e],s[t]=s.factory(t);s.load=function(e,t){var n,o=document.createElement("script");o.setAttribute("data-legalmonster","sven"),o.type="text/javascript",o.async=!0,o.src=i,(n=document.getElementsByTagName("script")[0]).parentNode.insertBefore(o,n),s.__project=e,s.__loadOptions=t||{}},s.widget=function(e){s.__project||s.load(e.widgetPublicKey),s.handleWidget(e)}}}();
type: "cookie",
widgetPublicKey: "xxxxxxxxxxxxxxxxx",
Notice that the value for widgetPublicKey will be different in your code snippet

Step 2: Add custom code

To insert the code snippet on your page, go to your Shopify dashboard and select "Online store" in the side menu. From the dropdown menu select "Themes".
To add custom code to your theme, you must select "Edit code" from the actions menu:
Select Edit code from the dropdown menu
You'll now enter Shopify's code editing interface.

Step 3: Edit theme.liquid

To correctly install the cookie widget, you must enter the widget code snippet in the file name "theme.liquid".
Select "theme.liquid" from the list of files in the editor:
The editor screen when "theme.liquid" is selected
The cookie widget code snippet will need to go right before the closing <body>-tag of your code. Navigate to the bottom of the code and insert your code snippet.
The highlighted code is your cookie widget code snippet.
Remember to save once you've added the code snippet.


Congratulations on completing your first step towards collecting compliant cookie consent. Pad your self on the back and know that our monster Sven is proud of you.
Last modified 1yr ago