I'm defining an intercom event in my rails controller like so:
object_controller.rb
@object.save
@intercom_event = 'object-saved'
In a partial that exists in my application.html.erb I am trying to run this script:
<script>
Intercom('trackEvent', '<%= @intercom_event %>');
</script>
The script runs and sends the event up to Intercom like its supposed to. I thought I am placing the ruby variable into the <script> tag correctly except the output for @intercom_event is: <%= @intercom_event %> when it should be: object-saved.
Additionally if I were to wrap this <script> tag in an if statement (so that it doesn't send an event every time the page is reloaded) like so:
<% if @intercom_event.present? %>
<script>
Intercom('trackEvent', '<%= @intercom_event %>');
</script>
<% end %>
It ignores the script altogether, even when @intercom_event is defined.