Adding custom code
Put your own HTML, CSS and JavaScript on a page with the Code element. Covers where to find it, how to edit the code and what to leave out.
The Code element puts your own HTML, CSS and JavaScript on a page. Use it for a third-party widget, an embed code or a script that the other elements do not cover.
Considerations
- The Advance group only shows when the builder is in Pro mode. Use the Basic and Pro toggle in the toolbar.
- Your code runs on your live storefront. Only add code you trust.
- Do not include
<html>,<head>or<body>tags. They can clash with other elements on the page.
Add the element
- From your Orbit dashboard, go to Storefront, then Pages, and open the page you want to edit.
- In the toolbox on the far left, click Elements.
- Open the Advance group and find Code, or search for it.
- Drag it onto the canvas and drop it where you want it.
- In the Orbit Commerce app, tap the menu button at the top left, then tap the arrow beside Storefront, then tap Pages.
- Tap the page, then tap Edit content at the top. The page editor opens and shows your page.
- Tap the section where you want the element, then tap inside it again where the element should go. A toolbar appears at the bottom, with a row above it that shows where you are, such as Columns, then Column 1, then the element you tapped.
- To add the element at the end of a column, tap the column in that row, such as Column 1, then tap the plus button in the toolbar. To add it straight after the element you tapped, tap the three dots in the toolbar, then Add element after.
- The Add an element sheet opens. Type code in Search elements, or tap Advanced in the row of groups and find Code there. The app has no Basic or Pro mode, so the Advanced group is always there.
- Tap Code, then tap Insert. The element is added to the page and its settings open in a sheet at the bottom of the screen.
The message Element added appears for a few seconds with Undo, in case you picked the wrong element.
To give the element a section of its own, tap the plus button in the middle of the bar at the bottom while nothing is selected. In the Add a section sheet, tap Blank, tap a layout such as Full width, then tap Insert. Then tap inside the new section to select its column, and carry on from step 4.
Note: On iPad, the menu is the sidebar on the left, and Edit content opens the full page builder instead, which works as in the Desktop steps. Tap Done at the top right to close it.
Add your code
- Click the Code element on the canvas. The settings panel opens on the right.
- On the Content tab, under Custom Code, click Edit Code.
- Paste or type your code in the editor.
- Click Save Changes. The code runs on the page in place of the element.
- In the page editor, tap the code element once to select its section and again to select it, then tap Edit in the toolbar. Right after you add one, its settings are already open in a sheet at the bottom of the screen. Drag the sheet up for more room.
- The Content tab opens with the Loading card open. Tap the Code box and paste or type your code. There is no separate code window and no save button. The app keeps what you type. The code also runs on the page in the editor, so drag the sheet down to check it before you publish.
- Above the box, switch on Load when visible if the code is a heavy embed, such as a widget, that can wait until shoppers scroll near it. Leave it off for analytics or tracking code that must run when the page loads.
- Tap Done.
If the code element is hard to tap on the page, select it from the list of sections instead. If something is selected, tap the back button at the top left once to clear the selection. Then tap Sections in the bar at the bottom, tap the arrow at the start of the section's card, tap Code in the list, then tap Edit in the toolbar.
Your code saves as a draft. To put it live, tap Publish at the top right, then Publish again to confirm. The message Published. Your changes are live. appears at the bottom of the screen, and the code runs on your live page in place of the element.
Settings
- Custom Code: the HTML, CSS and JavaScript for this element. The panel shows how many lines you have added, or Empty if there is nothing yet.
The Design tab has spacing settings only. Your code controls its own layout.
Related guides
Was this helpful?
0 people found this helpful