Skip to content

Commit

Permalink
Application.html template updates
Browse files Browse the repository at this point in the history
* Fixes apple-touch-icon links to use the Baseurl so they will work on all pages
* Moves supplemental analytics code into main JS file where Jquery is available.
  • Loading branch information
egardner committed Aug 22, 2017
1 parent 2975232 commit c295499
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
9 changes: 9 additions & 0 deletions source/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,13 @@ window.page.setupStoredData()
$(document).ready(() => {
window.page.ui = new UI()
prepareTransitions()

// Google Analytics: to handle pdfs, docs, xls
let analyticsTargets = "a[href$='pdf'],a[href$='rtf'],a[href$='doc'],a[href$='xls'],a[href*='bit.ly'],a[href$='csv'],a[href$='json'],a[href$='zip'],a[href$='ppt'],a[href*='epub'],a[href*='mobi']"

$(analyticsTargets).each(function (index) {
let pdfLabel = $(this).attr('href')
let pdfOnClick = "ga('send', 'pageview','" + pdfLabel + "');"
$(this).attr('onClick', pdfOnClick)
})
})
17 changes: 4 additions & 13 deletions source/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
%meta{name: "viewport", content: "width=device-width, initial-scale=1"}
%meta{ name: "apple-mobile-web-app-capable", content: "yes" }
%meta{ name: "apple-mobile-web-app-status-bar-style", content: "black" }
%link{ rel: "apple-touch-icon", sizes: "57x57", href: "apple-touch-icon-57x57.png" }
%link{ rel: "apple-touch-icon", sizes: "72x72", href: "apple-touch-icon-72x72.png" }
%link{ rel: "apple-touch-icon", sizes: "114x114", href: "apple-touch-icon-114x114.png" }
%link{ rel: "apple-touch-icon", sizes: "144x144", href: "apple-touch-icon-144x144.png" }
%link{ rel: "apple-touch-icon", sizes: "57x57", href: "#{config[:baseurl]}/apple-touch-icon-57x57.png" }
%link{ rel: "apple-touch-icon", sizes: "72x72", href: "#{config[:baseurl]}/apple-touch-icon-72x72.png" }
%link{ rel: "apple-touch-icon", sizes: "114x114", href: "#{config[:baseurl]}/apple-touch-icon-114x114.png" }
%link{ rel: "apple-touch-icon", sizes: "144x144", href: "#{config[:baseurl]}/apple-touch-icon-144x144.png" }

/ Open Graph
%meta{ property: "og:title", content: data.book.title.main }
Expand Down Expand Up @@ -55,15 +55,6 @@
ga('create', 'UA-8087223-1', 'auto');
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');
/ Google Analytics: to handle pdfs, docs, xls
:javascript
$(document).ready(function($) {
$("a[href$='pdf'],a[href$='rtf'],a[href$='doc'],a[href$='xls'],a[href*='bit.ly'],a[href$='csv'],a[href$='json'],a[href$='zip'],a[href$='ppt'],a[href*='epub'],a[href*='mobi']").each(function(index) {
pdfLabel = $(this).attr('href');
pdfOnClick = "ga('send', 'pageview','" + pdfLabel + "');";
$(this).attr("onClick", pdfOnClick);
});
});
/ Google Analytics: to handle outbound links
:javascript
var trackOutboundLink = function(url) {
Expand Down

0 comments on commit c295499

Please sign in to comment.