DataLook Docs
Install guides

Ruby on Rails

Install DataLook on Ruby on Rails — the plain script tag, or the first-party proxy that beats ad blockers. Both on one page.

Add the tag to your application layout.

Add the script to your layout <head>

app/views/layouts/application.html.erb
<script defer src="https://cdn.datalook.app/s.js" data-site="YOUR_SITE_ID"></script>

The proxy install serves both s.js and the collector from your own domain, so ad blockers — which match on domain, not path — can't see us. You rewrite one innocuous path prefix to our CDN; the script figures out the rest.

A catch-all controller forwards the prefix with Net::HTTP.

Add a route

config/routes.rb
match '/_axis/*path', to: 'datalook#proxy', via: [:get, :post]

Add the controller

app/controllers/datalook_controller.rb
require 'net/http'class DatalookController < ApplicationController  skip_before_action :verify_authenticity_token  TARGET = 'https://cdn.datalook.app'  def proxy    uri = URI("#{TARGET}/#{params[:path]}")    req = request.get? ? Net::HTTP::Get.new(uri) : Net::HTTP::Post.new(uri)    unless request.get?      req.body = request.raw_post      req['Content-Type'] = request.content_type || 'text/plain'    end    req['X-Forwarded-For'] = request.remote_ip    res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }    send_data res.body, type: res.content_type, disposition: 'inline', status: res.code  endend

Point the script at the prefix

<script defer src="/_axis/s.js" data-site="YOUR_SITE_ID"></script>

Heads up

Your server now sits between the visitor and us, so forward the visitor IP (X-Forwarded-For) or your country breakdown will collapse to your server location. The DNS proxy avoids this entirely — see the proxy overview.