Note: While our most popular guides have been translated into Spanish, some guides are only available in English.
Using Code Injection

You can add custom code and scripts to your site using the Code Injection area in Advanced Settings.

This is a Premium feature available in the current Website Business plan and higher:

  • Available in: All Business and Commerce plans
  • Available in: Legacy Personal plan (no longer available for new subscriptions)
  • Not available in: Current Personal plan
  • Trial: Available during a trial

To learn more, visit Premium features.

Watch a video

Before you begin

  • If you add code to Code Injection, we may ask you to disable it while editing your site. To learn more, visit Disabling scripts in preview.
  • To add JavaScript to a Code Injection field, surround the code with <script></script> tags.
  • We recommend adding CSS to the Custom CSS Editor instead of Code Injection. If you're adding it to Code Injection, surround the code with <style></style> tags.

When to use Code Injection

Use Code Injection to add HTML and scripts that enhance specific parts of your site. These might include live chat services, domain verification for custom email services, or site analytics.

Code Injection isn't intended for adding content or styles. To add content to your site, visit Building a page. To add custom CSS for styles, use the Custom CSS Editor.

Step 1 - Open Code Injection

In the Home Menu, click Settings, click Advanced, and then click Code Injection.

Step 2 - Add HTML code

Add valid HTML or scripts into the appropriate Code Injection fields for the header, footer, lock page, or order confirmation page.

Code added here is injected into the <head> tag on every page in your site.

Screen_Shot_2019-01-16_at_1.01.09_PM.png

Code added here is injected before the closing </body> tag on every page in your site.

Screen_Shot_2019-01-16_at_1.01.25_PM.png

Note: The footer area is defined by your template.

Lock page

The lock screen appears when a page or site is hidden behind a site-wide or page password. Code injected here displays above the lock screen's password field.

Although you can add code to this field, we recommend you use the Lock Screen panel to design your lock page instead. That way, you can add a background image or slideshow, adjust font styles, incorporate your logo, and more.

Screen_Shot_2019-01-16_at_1.01.32_PM.png

Order confirmation page

Code added here is injected into the order confirmation page that appears after a customer checks out. This works well for adding third-party tracking and affiliate programs to your store.

There are six tags you can use to insert information specific to the customer:

  • {orderId} – The unique ID of the confirmed order
  • {orderSubtotal} – The subtotal of the confirmed order
  • {orderSubtotalCents} – The subtotal of the confirmed order, in cents
  • {orderGrandTotal} – The grand total of the confirmed order
  • {orderGrandTotalCents} – The grand total of the confirmed order, in cents
  • {customerEmailAddress} – The customer's email address, as it was entered in the "Billing Info" section

Screen_Shot_2019-01-16_at_1.01.40_PM.png

Step 3 - Save

After adding your code, click Save.

5.png

Per-page Code Injection

You can also inject code into a specific page:

  1. Open the page while in the Pages panel.
  2. Hover over the content area.
  3. Click Settings.
  4. In the Page Settings window, click Advanced in the top-right corner.

Page Header Code Injection adds code to the <head> tag of that page. It won't display on Index landing pages.

In Blog Page Settings, Post Blog Item Code Injection adds code to every blog post.

  • Depending on your template, it will appear above or below the post content.
  • In templates with the Grid/stacked Blog Page, the code displays on the blog landing page and not on individual posts. 
NoteAjax loading may prevent CSS added to Code Injection from loading correctly. Add CSS to the CSS Editor instead.

Screen_Shot_2019-01-16_at_1.02.57_PM.png

Note: Adding or modifying code on your site is an advanced modification. We highly recommend that you have coding knowledge to use Code Injection. While we can't offer more help on this topic, there are many resources available that can point you in the right direction:

Was this article helpful?
105 out of 249 found this helpful