Skip to content

Commit

Permalink
Add google analytics data to download button, fix #968
Browse files Browse the repository at this point in the history
  • Loading branch information
hackartisan committed May 15, 2017
1 parent 1173a00 commit e06a66c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/views/hyrax/file_sets/media_display/_default.html.erb
@@ -1,6 +1,10 @@
<div class="no-preview">
<%= t('hyrax.works.show.no_preview') %>
<% if Hyrax.config.display_media_download_link? %>
<p/><%= link_to t('hyrax.file_set.show.download'), hyrax.download_path(file_set), target: "_new" %>
<p/><%= link_to t('hyrax.file_set.show.download'),
hyrax.download_path(file_set),
id: "file_download",
data: { label: file_set.id },
target: "_new" %>
<% end %>
</div>
2 changes: 2 additions & 0 deletions app/views/hyrax/file_sets/media_display/_image.html.erb
Expand Up @@ -8,6 +8,8 @@
<%= link_to hyrax.download_path(file_set),
data: { turbolinks: false },
target: :_blank,
id: "file_download",
data: { label: file_set.id },
class: "btn btn-default" do %>
<%= t('hyrax.file_set.show.downloadable_content.image_link') %>
<% end %>
Expand Down
Expand Up @@ -8,6 +8,8 @@
<%= link_to hyrax.download_path(file_set),
data: { turbolinks: false },
target: :_blank,
id: "file_download",
data: { label: file_set.id },
class: "btn btn-default" do %>
<%= t('hyrax.file_set.show.downloadable_content.office_link') %>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/hyrax/file_sets/media_display/_pdf.html.erb
Expand Up @@ -8,6 +8,8 @@
<%= link_to hyrax.download_path(file_set),
data: { turbolinks: false },
target: :_blank,
id: "file_download",
data: { label: file_set.id },
class: "btn btn-default" do %>
<%= t('hyrax.file_set.show.downloadable_content.pdf_link') %>
<% end %>
Expand Down
Expand Up @@ -15,6 +15,11 @@
expect(rendered).to have_css('a', text: 'Download the file')
end

it "includes google analytics data in the download link" do
expect(rendered).to have_css('a#file_download')
expect(rendered).to have_selector("a[data-label=\"#{file_set.id}\"]")
end

context "no download links" do
let(:link) { false }

Expand Down

0 comments on commit e06a66c

Please sign in to comment.