How to inject a snippet to all the urls of a theme?

Solved
Highlighted
Shopify Partner
46 0 3

How do I insert or append a snippet to all the URLs(pages, checkout, cart, home, products, etc ) of a theme. Is there any way?  Also, I have loaded a script using scriptTag API. Is there any way so that my script can cart abandonment?

0 Likes
Highlighted
Shopify Partner
1777 211 370

You can include your snippet into layout/theme.liquid under Shopify code editor, it'll get included into each and every page, except checkout pages.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Shopify Partner
46 0 3

I


@Visely-Team wrote:

You can include your snippet into layout/theme.liquid under Shopify code editor, it'll get included into each and every page, except checkout pages.



s there any library or something to inject programmatically? I am creating a widget so that I want the snippet injected before the head (not scriptTag). Or do we need to manually parse and place it? Also, how do I include it in the checkout page?

0 Likes
Highlighted
Shopify Partner
1777 211 370

You'll have to take care of it. Using Themes REST API, download the the asset, add your line, upload the asset back. Easiest would be to find the </head> and prepend your include. So it's not manual, but not too smart either :). Unfortunately, there are no other ways.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Shopify Partner
46 0 3

Also how do I inlcude it in checkout pages ? Is there any seprate API ? sorry to bother you


@Visely-Team wrote:

You'll have to take care of it. Using Themes REST API, download the the asset, add your line, upload the asset back. Easiest would be to find the </head> and prepend your include. So it's not manual, but not too smart either :). Unfortunately, there are no other ways.


 

0 Likes
Highlighted
Shopify Partner
1777 211 370

This is an accepted solution.

If the store is not on Shopify Plus, the only option here is the script tag that you can use to add stuff to Thank You page only. Checkout flow is mostly locked for modifications due to security reasons.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Shopify Partner
46 0 3

Thank you for your reply.

0 Likes