How To Make A Custom Script

You have a script or tag that you want to add to your site. We can help!

You can add that script anywhere in your site with the Civil Pixels custom script editor.

Add A New Script

To start, go to your Civil Pixels dashboard from the Shopify dashboard.

In the Custom Scripts section, click Add New.

You’ll be brought to an editor screen for your new script.

Put In Your Details & Code

Give your script a snazzy title so you can remember it later – don’t worry, only you can see this.

What you do now depends on whether the code you want to paste is surrounded by <script> tags. If you see these tags, remove everything in the code box and paste in your code as is.

If you don’t see <script> tags, paste your code between the <script></script> tags we provided.

For example,

if your code is:


var test = "hello";
console.log("test");

Then paste it into the code box between the<script> tags. The end result looks like:


<script>
var test = "hello";
console.log("test");
</script>

For the advanced, you can inject your store’s data into your script. Just follow our guide on variables here!

Pick When Your Script Should Activate

Now we can choose our triggers!

In the trigger section, you can choose where or when your code should fire. If you were given instructions to put it before the closing <head> tag or <body> tag, just pick that option under Activity or Location.

Under Activity or Location, you can choose to fire your code when a certain user activity occurs like Add to Cart or Purchase.

You can also choose specific pages for the code to fire. If you’d only like the code to fire on your home page or your cart page, just type that page’s URL under the Page triggers!

Wrap It Up

Once you’re done, you can click Save Draft to save your changes without publishing them to your store. Or just click Publish to push your changes live to your shop!

 

Was this article helpful?

Related Articles