Skip to content

Instantly share code, notes, and snippets.

@maccman
Created December 26, 2016 23:37
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Clearbit Reveal/Drift integration
drift.on('ready',function(api, payload) {
api.showWelcomeOrAwayMessage(<%== @options.to_json %>);
});
get '/drift.js' do
reveal = Clearbit::Reveal.find(ip: request.ip)
content_type 'application/javascript'
qualified =
reveal &&
reveal.company.metrics.employees.to_i >= 30 &&
%{private public}.include?(reveal.company.type)
if qualified
unless reveal.fuzzy
name = reveal.company.name.gsub(/\W/, '')
message = %{We ♥ #{name}. Have any questions?}
end
@options = {
showAvatar: true,
slide: true,
message: message,
}
erb :'site/drift/show'
else
200
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment