You’ll probably want to add some scripts to your store front<

Edit config/initializers/shopify_app.rb and add

config.scripttags = [
  {event:'onload', src: "#{ENV['AWS_S3_BUCKET_URL']}/myscript.js"}

When the app is installed it will automatically add your script to the store front.

The reason for using AWS is that it scale much better than hosting the scripts yourself. The script will be called with ?shop=SHOPDOMAIN appended.

If you need to load store specific content then use the shop parameter and load the store specific content from another URL host on AWS (i.e. SHOPDOMAIN.js)

Add the AWS SDK to the Gemfile

# Use the AWS SDK to host the scripttag on S3
gem 'aws-sdk', '~> 2.5', '>= 2.5.6'

Install the gem

bundle install

Now create a job to update SHOPDOMAIN.js file.

rails g job UploadTag

The jobs should update the SHOPDOMAIN.js file on AWS

class UploadTagJob < ApplicationJob
  def perform(shop_id)
    shop = Shop.find shop_id

    s3 =

    # Replace this with your code to generate the config for the store
    config = {}

    s3.put_object(bucket: ENV['AWS_S3_BUCKET'],
                  key: "#{ENV['AWS_S3_KEY_PREFIX']}/data/#{shop.shopify_domain}.js",
                  acl: 'public-read',
                  content_type: 'application/json',
                  body: config.to_json)
                  puts "#{ENV['AWS_S3_KEY_PREFIX']}/data/#{shop.shopify_domain}.js"

Make sure the queue_as :default is removed

You should call this inside your application any time the config changes.

Add the following to

export AWS_REGION='us-west-2'
export AWS_ACCESS_KEY_ID='xxxxxxxxxxx'
export AWS_SECRET_ACCESS_KEY='xxxxxxxxxx'
export AWS_S3_ENDPOINT=''