projectblacklight / spotlight

Spotlight enables librarians, curators, and others who are responsible for digital collections to create attractive, feature-rich websites that highlight these collections.
Other
161 stars 65 forks source link

Google Analytics partial throwing javascript error #1793

Open travisLilleberg opened 7 years ago

travisLilleberg commented 7 years ago

I've set up google analytics as and the dashboard page is working, but the javascript snippet is not being rendered correctly in the application.

In the console I'm getting (index):396 Uncaught SyntaxError: Unexpected token &, and when I click through to the line in question it appears to be incorrectly encoded: ga('create', "my-property-id", 'auto');

My initializer is like so:

 # ==> Google Analytics integration                                                        
 # Spotlight::Engine.config.analytics_provider = nil                                       
 Spotlight::Engine.config.ga_pkcs12_key_path = Rails.application.secrets.ga_pkcs12_key_path
 Spotlight::Engine.config.ga_web_property_id = Rails.application.secrets.ga_web_property_id
 Spotlight::Engine.config.ga_email = Rails.application.secrets.ga_email                   
 # Spotlight::Engine.config.ga_analytics_options = {}                                      
 # Spotlight::Engine.config.ga_page_analytics_options = config.ga_analytics_options.merge(limit: 5)

And the secrets file on my prod is:

production:
   ga_web_property_id: "my-property-id"
   . . .

I've tried removing the quotes from the value in secrets.yml, clearing caches and restarting but the problem remains. Do I have this set up incorrectly?

Thanks for any help,

-- Travis Lilleberg

EDIT: Forgot to mention I'm on Spotlight v0.30.0 .

travisLilleberg commented 7 years ago

For the time being, I've overwrote ga('create', <%= Spotlight::Engine.config.ga_web_property_id.to_json %>, 'auto'); to ga('create', <%= Spotlight::Engine.config.ga_web_property_id.to_json.html_safe %>, 'auto'); in _analytics.html.erb.