-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
Part of #647 (comment)
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$(document).ready(function() { | ||
// check if the Google Analytics function is available | ||
if (typeof ga == 'function') { | ||
function trackFollow() { | ||
ga('send', 'event', 'following', 'click Follow buttom'); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
}; | ||
|
||
function trackUnsubscribe() { | ||
ga('send', 'event', 'following', 'click Unsubscribe buttom'); | ||
}; | ||
|
||
$('.track-request-action').click(function(e) { trackFollow(); }); | ||
$('.track__action').click(function(e) { trackFollow(); }); | ||
|
||
$('.unsubscribe__action').click(function(e) { trackUnsubscribe() }); | ||
$('.unsubscribe-request-action').click(function(e) { trackUnsubscribe() }); | ||
} | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
<link href='https://fonts.googleapis.com/css?family=Maven+Pro:400,700%7CActor' rel='stylesheet' type='text/css'> | ||
<%= javascript_include_tag 'event_tracking' unless AlaveteliConfiguration::ga_code.empty? || (@user && @user.super?) %> |
4 comments
on commit 108c9d9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke production:
ActionView::Template::Error (event_tracking.js isn't precompiled):
1: <link href='https://fonts.googleapis.com/css?family=Maven+Pro:400,700%7CActor' rel='stylesheet' type='text/css'>
2: <%= javascript_include_tag 'event_tracking' unless AlaveteliConfiguration::ga_code.empty? || (@user && @user.super?) %>
lib/themes/righttoknow/lib/views/general/_before_head_end.html.erb:2:in `_lib_themes_righttoknow_lib_views_general__before_head_end_html_erb___617197513_118481350'
It wasn't a problem in development because production is configured to not fall back to the asset pipeline if an asset isn't precompiled, where as development is not. I believe this is because the file isn't in the precompile array.
Could this be an issue with Alaveteli not precompiling javascripts in the theme assest
directory like it does for stylesheets? @garethrees am I just doing this in the wrong way? I’d really appreciate your advice on this :) Adding a script like this is how I interpreted Alaveteli wants us to based on this bit of the Theme docs http://alaveteli.org/docs/customising/themes/#changing-other-styling .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't a problem in development…
Yeah, that's not ideal behaviour. Sounds like its still a mess.
I believe this is because the file isn't in the precompile array.
Yeah, that'll be it. I think you should be able to add it to the precompile array in your alavetelitheme.rb
, after the theme assets have been added to the load path:
Rails.application.config.assets.precompile += ['event_tracking.js']
We don't appear to have any themes that add custom JS like this, so I guess you'll be the pioneers of this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @garethrees I'll pioneer away then 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the trick @garethrees 3c85154
I could add that to the docs, or write something to include any .js put into /assets/javascripts . That would make the current docs correct and probably be easier for people. You still need to link to these files in your app, so we wouldn't be automatically serving stuff to users, which was a concern for me.
Typo here. “Buttom”