Which Shopify Theme File Should You Edit to Add the SeaText Snippet?
The standard file to edit is layout/theme.liquid in your Shopify theme, where you paste the SeaText JavaScript snippet before the closing </body> tag. Alternatively, you can place the snippet in a section file or...
The Short Answer: Where to Add the SeaText Snippet
SeaText’s official integration guide points to layout/theme.liquid as the primary file. You open your Shopify admin, go to Online Store > Themes > Actions > Edit code, locate the Layout folder, open theme.liquid, and paste the JavaScript snippet just before </body>. This loads the script on every page of your store.
For the optional product-description tag feature, you also edit product.liquid (or your product-template file) to wrap the product description output. But the question is about the main snippet – and theme.liquid is the default answer.
However, you have three viable file locations. Choosing the right one depends on your theme structure, your comfort with code, and whether you need per-page control.
Decision Criteria: Three File Locations Compared
1. layout/theme.liquid – Global Scope
How it works: This file controls the outer layout of your entire store. Every page uses it, so any snippet placed here runs on all pages.
Pros:
• Simple, one‑time edit.
• Guaranteed to load on every page – no risk of missing a template.
• Well‑documented by SeaText.
Cons:
• Affects every page, even those where you might not want the script (e.g., thank‑you pages).
• Changes require theme code editing skills.
• If you update your theme, you may need to re‑add the snippet.
2. Sections – Template‑Specific Control
How it works: In Shopify’s theme file structure, sections (e.g., footer.liquid, header.liquid, or custom sections) are reusable blocks. You can paste the SeaText snippet inside a section that appears only on certain templates.
Pros:
• You can control which pages load the script by including the section only in specific templates.
• Sections can be edited through the theme editor (if you expose the snippet as a setting).
• Easier to manage if you use a theme with section‑based layouts.
Cons:
• Requires understanding of your theme’s section structure.
• The snippet may not load on all pages unless the section is included in every template.
• More complex to set up than theme.liquid.
3. App Blocks (Online Store 2.0) – No‑Code Flexibility
How it works: If your theme supports Online Store 2.0 (most modern themes do), you can add the SeaText snippet as an app block. This is done through the theme editor by adding a “custom liquid” block and pasting the snippet there.
Pros:
• No direct code editing – you use the theme editor’s block system.
• Easy to move, remove, or duplicate blocks.
• Works well for non‑technical store owners.
Cons:
• Requires a theme that supports app blocks (most do, but not all).
• Block placement is limited to areas where you can add blocks (e.g., footer, sidebar, product page).
• May not be available on all page types.
| Criteria | layout/theme.liquid | Sections | App Blocks |
|---|---|---|---|
| Best use case | Simple, global script installation | Per‑template control | No‑code, theme‑editor approach |
| Setup effort | Low – one file edit | Medium – need to find/choose section | Low – add block in editor |
| Control & flexibility | High – script runs everywhere | High – can restrict to specific pages | Medium – limited by block locations |
| Update ease | Manual – edit code again | Manual – edit code or section settings | Easy – drag block, change in editor |
| Risk of breaking | Low if copied correctly | Low if section is used correctly | Very low – no code editing |
Step‑by‑Step: How to Edit theme.liquid
This is the method SeaText recommends for most users. Follow these steps:
- Log in to your Shopify admin and go to Online Store > Themes.
- Click Actions > Edit code for your active theme.
- In the left file list, open the Layout folder and click theme.liquid.
- Scroll to the bottom of the file and find the closing
</body>tag. - Paste the SeaText JavaScript snippet (from your SeaText account) just before
</body>. - Click Save.
That’s it. The snippet is now active on every page. To verify, open any store page, view the page source, and look for the SeaText script.
Step‑by‑Step: How to Add the Snippet to a Section
- In the theme code editor, locate the Sections folder.
- Choose a section that appears on the pages you want (e.g.,
footer.liquid). - Paste the snippet inside that section, ideally near the bottom of the file.
- Save. The snippet will load only on pages that include that section.
Step‑by‑Step: How to Add the Snippet as an App Block
- In your Shopify admin, go to Online Store > Themes > Customize.
- Select the page template where you want the snippet (e.g., Home page, Product page).
- Click Add block and choose Custom liquid.
- Paste the SeaText snippet into the liquid code box.
- Position the block where you want it (e.g., Footer).
- Save. The block will appear on that template.
Decision Rule: Which File Should You Choose?
Use layout/theme.liquid if: you want the script on every page, you are comfortable editing code, and you want the simplest installation.
Use sections if: you need the script only on specific templates (e.g., product pages only) or you want to keep the snippet separate from the layout file.
Use app blocks if: you prefer a no‑code approach, your theme supports Online Store 2.0, and you want to manage the snippet through the theme editor.
Limitation of this rule: If your theme is heavily customized or uses a third‑party builder, you may need to adapt the method. Always test on a duplicate theme first.
Key Facts from SeaText’s Integration Guide
| Fact | Detail |
|---|---|
| Required account | You need a SeaText AI account. If you don’t have one, create it first. |
| Primary file | layout/theme.liquid – paste code before </body> |
| Additional file for product description | product.liquid (or product‑template.liquid) – wrap the description output |
| Domain restriction | One SeaText account per domain. Use separate accounts for dev and production domains. |
| Security | The AI is inert until activated – installing the snippet alone does not change your site content. |
| Testing | After saving, preview a page and inspect the HTML source for the data- attribute. |
| Localhost restriction | Local development URLs are blocked. Use a real domain for testing. |
Limitations and When This Advice Does Not Apply
This advice applies to standard Shopify themes. It does not apply if:
- Your theme uses a custom framework that overrides the default layout system. In that case, consult the theme developer.
- You are using a headless Shopify setup (e.g., Hydrogen, Next.js). The snippet needs to be added to your front‑end code, not a theme file.
- You want to control the snippet on a per‑page basis using Shopify’s built‑in “theme.liquid” conditionals. You can use
{% if template.name == 'product' %}inside theme.liquid to load the script only on certain templates – that is a variation of the theme.liquid method. - You are using a third‑party script manager (e.g., Google Tag Manager). In that case, you can deploy the snippet via GTM instead of editing theme files.
Frequently Asked Questions
Where exactly in theme.liquid should I paste the snippet?
Paste it just before the closing </body> tag. This ensures the script loads after the page content, which is recommended for performance.
Is it safe to edit theme.liquid?
Yes, if you copy the snippet exactly as provided. Always back up your theme before editing. You can duplicate your theme in the Shopify admin as a safety net.
Can I add the snippet to other files like header.liquid?
You can, but it’s not recommended. Headers load early, and placing the script there may block rendering. The </body> position is best for performance.
Do I need to edit product.liquid as well?
Only if you want to use the product description tag feature. The main SeaText snippet is separate. If you don’t need that feature, you can ignore product.liquid.
What if my theme uses Online Store 2.0?
You can use app blocks, which let you add the snippet through the theme editor without touching code. This is the easiest method for modern themes.
How do I test that the snippet is working?
After saving, open any page on your store, right‑click and select “View page source”. Search for “seatext” or check for the data- attribute mentioned in the SeaText documentation.
What happens if I use the same snippet on multiple domains?
SeaText requires a separate account per domain. Using the same snippet on multiple domains will not work reliably. Create a new account for each domain.
Further reading and comparison sources
These external sources provide additional context for evaluating the topic. Their inclusion is not an endorsement.
Learn more
Visit the website for more information.