Skip to content

Commit 6d81d24

Browse files
committed
fix ga4 nits and prepare more content data
1 parent 6786289 commit 6d81d24

6 files changed

Lines changed: 67 additions & 39 deletions

File tree

‎_content/monographs/what-the-buddha-taught_rahula-w.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ pages: 192
2020
The classic introduction to Buddhist philosophy to the modern reader.
2121

2222
Walpola Rahula's book has had a dramatic impact on the shape of Buddhist thought in the West but its interest is far from merely historical: it remains one of the most lucid and sympathetic introductions available in English, even today. Recommended for newcomers to Buddhism or anyone looking for a solid grounding in Buddhist doctrine.
23+
24+
You can also find the book read out loud [on YouTube](https://youtu.be/sl3jKFTKkuI){:ga-event-value="1"}.

‎_includes/content_filelinks.html‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
{% include content_path.liquid content=include.content %}
22
<div class="content_links">
3-
{% assign value = include.content.base_value %}{% if include.content.status=="featured" %}{% assign value = value | times: site.data.ga.featured_value_multiplier %}{% endif %}
43
{% if include.content.external_url %}
5-
<a class="btn" {% if include.newtab %}target="_blank"{% endif %} data-content-path="{{ content_path }}" ga-event-value="{{ value }}" href="{{ include.content.external_url }}"{% for nrh in site.data.content.noreferrerhosts %}{% if include.content.external_url contains nrh %} rel="noreferrer"{% break %}{% endif %}{% endfor %}><i class="fa{% if include.content.external_url contains "youtu" %}b fa-youtube"></i> YouTube{% elsif include.content.external_url contains "//www.academia.edu/" %}c-academia"></i>cademia.edu{% else %}s fa-{% assign ext = include.content.external_url | slice: -4, 4 %}{% if ext == ".pdf" %}file-pdf"></i> pdf{% elsif ext == ".mp3" %}file-audio"></i> mp3{% elsif ext == ".zip" %}file-archive"></i> zip{% else %}{% case include.content.category %}{% when "av" %}volume-up{% when "booklets" %}book-open{% when "monographs" %}book-open{% else %}globe{% endcase %}"></i> Online{% endif %}{% endif %}</a>
4+
{% assign linkfmt = "Unknown/HTML" %}
5+
{%- capture linkbody -%}<i class="fa{% if include.content.external_url contains "youtu" %}{% assign linkfmt = "YouTube" %}b fa-youtube"></i> YouTube{% elsif include.content.external_url contains "//www.academia.edu/" %}c-academia"></i>cademia.edu{% assign linkfmt = "Academia.edu" %}{% else %}s fa-{% assign ext = include.content.external_url | slice: -4, 4 %}{% if ext == ".pdf" %}{% assign linkfmt = "pdf" %}file-pdf"></i> pdf{% elsif ext == ".mp3" %}{% assign linkfmt = "mp3" %}file-audio"></i> mp3{% elsif ext == ".zip" %}{% assign linkfmt = "zip" %}file-archive"></i> zip{% else %}{% if ext == ".htm" %}{% assign linkfmt = "htm" %}{% elsif ext == "html" %}{% assign linkfmt = "html" %}{% endif %}{% case include.content.category %}{% when "av" %}volume-up{% when "booklets" %}book-open{% when "monographs" %}book-open{% else %}globe{% endcase %}"></i> Online{% endif %}{% endif %}{%- endcapture -%}
6+
<a class="btn" {% if include.newtab %}target="_blank"{% endif %} {% include content_link_data_attributes.html content=c linktype="Main External URL" linkfmt=linkfmt %} href="{{ include.content.external_url }}"{% for nrh in site.data.content.noreferrerhosts %}{% if include.content.external_url contains nrh %} rel="noreferrer"{% break %}{% endif %}{% endfor %}>{{ linkbody }}</a>
67
{% endif %}
78
{% if include.content.file_links.size > 0 %}
89
{%- for link in include.content.file_links -%}
9-
{% assign i = forloop.index | minus: 1 %}
10-
<a class="btn" {% if include.newtab %}target="_blank"{% endif %} ga-event-value="{{ value }}" data-content-path="{{ content_path }}" ga-event-label="{{ link }}" href={{ site.data.content.filehost | append: link }}><i class="fa{% case include.content.formats[i] %}{% when "pdf" %}r fa-file-pdf{% when "jpeg" %}r fa-file-image{% when "mp3" %}r fa-file-audio{% when "m4a" %}r fa-file-audio{% when "epub" %}s fa-tablet-alt{% when "png" %}r fa-file-image{% when "mp3s" %}r fa-file-open{% when "zip" %}r fa-file-archive{% when "pdfs" %}r fa-file-open{% when "wma" %}r fa-file-audio{% else %}r fa-file{% endcase %}"></i> {{ include.content.formats[i] }}</a>
10+
{% assign linkfmt = include.content.formats[forloop.index0] %}
11+
<a class="btn" {% if include.newtab %}target="_blank"{% endif %} {% include content_link_data_attributes.html content=c linktype="Self-Hosted" linkfmt=linkfmt %} ga-event-label="{{ link }}" href={{ site.data.content.filehost | append: link }}><i class="fa{% case linkfmt %}{% when "pdf" %}r fa-file-pdf{% when "jpeg" %}r fa-file-image{% when "mp3" %}r fa-file-audio{% when "m4a" %}r fa-file-audio{% when "epub" %}s fa-tablet-alt{% when "png" %}r fa-file-image{% when "mp3s" %}r fa-file-open{% when "zip" %}r fa-file-archive{% when "pdfs" %}r fa-file-open{% when "wma" %}r fa-file-audio{% else %}r fa-file{% endcase %}"></i> {{ linkfmt }}</a>
1112
{%- endfor -%}
1213
{%- endif -%}
1314
{%- if include.content.drive_links.size > 0 -%}
1415
{%- for link in include.content.drive_links -%}
15-
{% assign i = forloop.index | minus: 1 %}
16-
<a class="btn" {% if include.newtab %}target="_blank"{% endif %} ga-event-value="{{ value }}" data-content-path="{{ content_path }}" ga-event-label="drive.google.com/{{ content_path }}.{{ include.content.formats[i] }}" href="{{ link }}"><i class="fa{% if link contains "drive.google.com" %}b fa-google-drive{% elsif link contains "play.google.com" %}b fa-google-play{% else %}s fa-globe{% endif %}"></i> {{ include.content.formats[i] }}</a>
16+
{% assign linkfmt = include.content.formats[forloop.index0] %}
17+
<a class="btn" {% if include.newtab %}target="_blank" {% endif %}{% include content_link_data_attributes.html content=c linktype="Google Drive" linkfmt=linkfmt %} ga-event-label="drive.google.com/{{ content_path }}.{{ linkfmt }}" href="{{ link }}"><i class="fa{% if link contains "drive.google.com" %}b fa-google-drive{% elsif link contains "play.google.com" %}b fa-google-play{% else %}s fa-globe{% endif %}"></i> {{ linkfmt }}</a>
1718
{%- endfor -%}
1819
{%- endif -%}
1920
{% if page.source_url %}
20-
<a class="btn" href="{{ include.content.source_url }}" {% if include.newtab %}target="_blank"{% endif %} data-content-path="{{ content_path }}" ga-event-value="{{ value }}"><i class="fas fa-route"></i> Origin</a>
21+
<a class="btn" href="{{ include.content.source_url }}" {% if include.newtab %}target="_blank"{% endif %} {% include content_link_data_attributes.html content=c linktype="Source" linkfmt="Unknown/HTML" %}"><i class="fas fa-route"></i> Origin</a>
2122
{% endif %}
2223
{%- assign showworldcat = false -%}
2324
{%- unless include.content.source_url or include.content.external_url or include.content.file_links or include.content.drive_links.size > 0 or include.newtab -%}
2425
{%- assign showworldcat = true -%}
2526
{%- endunless -%}
2627
{%- if include.content.excerpt_url -%}
2728
{%- if showworldcat -%}<details class="copyright details-reset"><summary>{%- endif -%}
28-
<a class="btn" {% if include.newtab %}target="_blank" {% endif %}href="{{ include.content.excerpt_url }}" ga-event-value="{{ value | divided_by: 2 }}" data-content-path="{{ content_path }}" ga-event-label="{{ include.content.excerpt_url }}"><i class="fas fa-book-reader"></i> Preview</a>
29+
<a class="btn" {% if include.newtab %}target="_blank" {% endif %}href="{{ include.content.excerpt_url }}" {% include content_link_data_attributes.html content=c linktype="Preview" linkfmt="html" %} ga-event-label="{{ include.content.excerpt_url }}"><i class="fas fa-book-reader"></i> Preview</a>
2930
{%- endif -%}
3031
{%- if showworldcat -%}
3132
{%- unless include.content.excerpt_url -%}<details class="copyright details-reset"><summary>{%- endunless -%}
3233
{%- capture authors -%}{% include content_authors_string.html content=include.content %}{%- endcapture -%}
3334
{% assign authors = authors | strip_html | strip | cgi_escape %}
34-
<a class="btn" href="https://www.worldcat.org/{% if include.content.oclc %}oclc/{{ include.content.oclc }}{% else %}search?q=ti%3A{{ include.content.title | markdownify | strip_html | strip | cgi_escape }}{% if authors %}+au%3A{{ authors }}{% endif %}{% if include.content.category == 'monographs' %}&fq=x0%3Abook+%3E+ln%3Aeng{% endif %}&qt=advanced{% endif %}"><i class="fas fa-binoculars"></i> WorldCat&trade;</a>
35+
<a class="btn" {% include content_link_data_attributes.html content=c linktype="WorldCat" linkfmt="html" %} ga-event-label="worldcat.org/{{ content_path }}" href="https://www.worldcat.org/{% if include.content.oclc %}oclc/{{ include.content.oclc }}{% else %}search?q=ti%3A{{ include.content.title | markdownify | strip_html | strip | cgi_escape }}{% if authors %}+au%3A{{ authors }}{% endif %}{% if include.content.category == 'monographs' %}&fq=x0%3Abook+%3E+ln%3Aeng{% endif %}&qt=advanced{% endif %}"><i class="fas fa-binoculars"></i> WorldCat&trade;</a>
3536
<i class="far fa-question-circle"></i>
3637
</summary><div>
3738
<i class="far fa-copyright"></i> This fine, Copyrighted work cannot be shared {% if include.content.excerpt_url %}in its entirety{% else %}directly{% endif %}, however WorldCat&trade; can help you find a copy at a nearby library{% if include.content.category == 'monographs' %} or wherever you get books{% endif %}.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{%- assign c = include.content -%}
2+
{%- include content_path.liquid content=c -%}
3+
{%- assign value = c.base_value -%}
4+
{%- if c.status == "featured" -%}{%- assign value = value | times: site.data.ga.featured_value_multiplier -%}{%- endif -%}
5+
{%- if include.linktype == "Preview" -%}{%- assign value = value | times: 0.5 -%}{%- endif -%}
6+
{%- if include.linktype == "WorldCat" -%}{%- assign value = 0.15 -%}{%- endif -%}
7+
ga-event-value="{{ value }}" data-content-path="{{ content_path }}" data-content-link-type="{{ include.linktype }}" data-content-link-ext="{{ include.linkfmt }}" data-content-category="{{ c.category }}" data-content-subcat="{{ c.subcat }}" data-content-course="{{ c.course | default: 'archive' }}"
8+
{%- comment -%}
9+
Only the common, data attributes are added here.
10+
The specific HREFs, etc are added in-situ
11+
{%- endcomment -%}

‎_includes/content_title.html‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{% assign c = include.content %}{% assign category = c.path | split: '/' %}{% assign category = category[1] %}
2-
{% assign value = c.base_value %}{% if c.status == "featured" %}{% assign value = value | times: site.data.ga.featured_value_multiplier %}{% endif %}
32
{% include_cached content_icon.html category=category subcat=c.subcat %}
43
{% include content_path.liquid content=c %}
5-
<span id="{{ c.slug }}">{% if c.external_url %}<a target="_blank" data-content-path="{{ content_path }}" ga-event-value="{{ value }}" href="{{ c.external_url }}"{% for nrh in site.data.content.noreferrerhosts %}{% if c.external_url contains nrh %} rel="noreferrer"{% break %}{% endif %}{% endfor %}>{% endif %}{{ c.title | markdownify | remove: '<p>' | remove: '</p>' }}{% if c.authors.size > 0 or c.reader %} – {% include content_authors_string.html content=c %}{% endif %}{% if c.external_url %}</a>{% endif %}</span>
6-
{% if c.drive_links %}<span>{% for link in c.file_links %}<span class="inline_drive_link"> (<a target="_blank" ga-event-value="{{ value }}" ga-event-label="{{ link }}" data-content-path="{{ content_path }}" href="{{ site.data.content.filehost | append: link }}"><i class="fa{% case c.formats[forloop.index0] %}{% when "pdf" %}r fa-file-pdf{% when "mp3" %}r fa-file-audio{% when "m4a" %}r fa-file-audio{% when "epub" %}s fa-tablet-alt{% when "png" %}r fa-file-image{% when "mp3s" %}r fa-file-open{% when "zip" %}r fa-file-archive{% when "pdfs" %}r fa-file-open{% when "wma" %}r fa-file-audio{% else %}r fa-file{% endcase %}"></i>.{{ c.formats[forloop.index0] }}</a>)</span>{% endfor %}{% for link in c.drive_links %}{% assign index = forloop.index | minus: 1 %}<span class="inline_drive_link"> (<a target="_blank" ga-event-value="{{ value }}" ga-event-label="drive.google.com/{{ content_path }}.{{ c.formats[index] }}" data-content-path="{{ content_path }}" href="{{ link }}"><i class="fa{% if link contains "drive.google.com" %}b fa-google-drive{% elsif link contains "play.google.com" %}b fa-google-play{% else %}s fa-globe{% endif %}"></i>.{{ c.formats[index] }}</a>)</span>{% endfor %}</span>{% endif %}
4+
<span id="{{ c.slug }}">{% if c.external_url %}<a target="_blank" {% include content_link_data_attributes.html content=c linktype="Main External URL" linkfmt="Unknown/HTML" %} href="{{ c.external_url }}"{% for nrh in site.data.content.noreferrerhosts %}{% if c.external_url contains nrh %} rel="noreferrer"{% break %}{% endif %}{% endfor %}>{% endif %}{{ c.title | markdownify | remove: '<p>' | remove: '</p>' }}{% if c.authors.size > 0 or c.reader %} – {% include content_authors_string.html content=c %}{% endif %}{% if c.external_url %}</a>{% endif %}</span>
5+
{% if c.drive_links %}<span>
6+
{%- for link in c.file_links -%}
7+
{%- assign linkfmt = c.formats[forloop.index0] -%}
8+
<span class="inline_drive_link"> (<a target="_blank" ga-event-label="{{ link }}" {% include content_link_data_attributes.html content=c linktype="Self-Hosted" linkfmt=linkfmt %} href="{{ site.data.content.filehost | append: link }}"><i class="fa{% case linkfmt %}{% when "pdf" %}r fa-file-pdf{% when "mp3" %}r fa-file-audio{% when "m4a" %}r fa-file-audio{% when "epub" %}s fa-tablet-alt{% when "png" %}r fa-file-image{% when "mp3s" %}r fa-file-open{% when "zip" %}r fa-file-archive{% when "pdfs" %}r fa-file-open{% when "wma" %}r fa-file-audio{% else %}r fa-file{% endcase %}"></i>.{{ linkfmt }}</a>)</span>
9+
{%- endfor -%}
10+
{%- for link in c.drive_links -%}
11+
{%- assign linkfmt = c.formats[forloop.index0] -%}
12+
<span class="inline_drive_link"> (<a target="_blank" ga-event-label="drive.google.com/{{ content_path }}.{{ linkfmt }}" {% include content_link_data_attributes.html content=c linktype="Google Drive" linkfmt=linkfmt %} href="{{ link }}"><i class="fa{% if link contains "drive.google.com" %}b fa-google-drive{% elsif link contains "play.google.com" %}b fa-google-play{% else %}s fa-globe{% endif %}"></i>.{{ linkfmt }}</a>)</span>
13+
{%- endfor -%}</span>{%- endif -%}

‎_layouts/default.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
{%- endcase -%}
4747
{%- if jekyll.environment == 'production' and site.google_analytics -%}
4848
<script>
49+
window.WEBSITE_SECTION = '{{ page.section }}';
4950
if(!(window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || localStorage.getItem("doNotTrack") == "1") || localStorage.getItem('TRACK') == "1") {
5051
function mkscrpt(g,i,o,a,m,s){i=window;s=document;o='script';a=s.createElement(o),
5152
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);}

‎assets/js/buggytrack.js‎

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,46 @@ const BuggyTracker = function (d) {
1717
const courser = /^\/courses\/([a-z_-]+)[\/]?([a-z0-9_-]*)$/;
1818
const blogr = /^\/blog\/20[2-7][0-9]\/[01][0-9]\/[0-3][0-9]\/[a-z_-]+$/;
1919
const lp = d.createElement('a');
20-
const whenceContent=function(referrer,r,l,m){
20+
function whenceContent(referrer,r,l,m){
2121
lp.href=referrer;l=d.location;
2222
if (lp.host!=l.host) return null;
2323
if (referrer) r=lp.pathname; else r='';
24-
if (r == '/search/') return "search-results";
25-
if (r == '/library/highlights') return "highlights";
26-
if (r == '/content/random/') return "randomizer";
27-
if (r == '/exclusive/') return "exclusive-content-list";
24+
if (r == '/search/') return "Search Results";
25+
if (r == '/library/highlights') return "Highlights";
26+
if (r == '/content/random/') return "Randomizer";
27+
if (r == '/exclusive/') return "Exclusive Content";
2828
l = l.pathname; m = l.match(tagr) || r.match(tagr);
29-
if(m) return m[1]+"-tag-page";
29+
if(m) return "Tag Page: "+m[1];
3030
m = l.match(courser) || r.match(courser);
31-
if(m) return m[1]+"-course";
31+
if(m) return "Course: "+m[1];
3232
m = l.match(blogr) || r.match(blogr);
33-
if(m) return "blog-post";
33+
if(m) return "Blog Post";
3434
m = r.match(/^\/content\/([a-z]+)\/$/);
35-
if(m) return "master-"+m[1]+"-list";
35+
if(m) return "Master "+m[1]+" List";
3636
m = r.match(/^\/content\/([a-z]+)\/([a-z0-9_-]+)$/);
37-
if(m) return "related-content";
37+
if(m) return "Related Content";
3838
m = r.match(/^\/publishers\/([a-z-]+)$/);
39-
if(m) return "publisher-page";
39+
if(m) return "Publisher Page";
4040
m = r.match(/^\/authors\/([a-z-]+)$/);
41-
if(m) return "author-page";
41+
if(m) return "Author Page";
4242
m = r.match(/^\/series\/([a-z-]+)$/);
43-
if(m) return "series-page";
43+
if(m) return "Series Page";
4444
m = r.match(/^\/journals\/([a-z-]+)$/);
45-
if(m) return "journal-page";
45+
if(m) return "Journal Page";
4646
return null;
47-
};
48-
const whenceLink=function(link,l,gp){
47+
}
48+
function linkType(link,l,gp){
4949
l=d.location.pathname; gp=link.parentElement.parentElement;
50-
if(link.parentElement.className=='courselink' && l=='/courses/') return 'external-course-list';
51-
if(link.className=='f3' && l=='/courses/') return 'mit-course-list';
52-
if(gp.className=='social-media-list') return 'social-media-list';
53-
if(gp.tagName=='UL' && l=='/sources/') return 'sources-list';
54-
return null;
55-
};
56-
const getGAUID = function(){
50+
if(link.parentElement.className=='courselink' && l=='/courses/') return 'External Course';
51+
if(link.className=='f3' && l=='/courses/') return 'MIT Course';
52+
if(gp.className=='social-media-list') return 'Social Media Link';
53+
if(gp.tagName=='UL' && l=='/sources/') return 'Sources Page Link';
54+
return 'Link';
55+
}
56+
function getGAUID(){
5757
try{return d.cookie.match(/_ga=(.+?);/)[1].split('.').slice(-2).join(".");}
5858
catch(e){return null;}
59-
};
59+
}
6060
this.getUID=function(){if(!this._uid){
6161
this._uid = localStorage.getItem("uid") || getGAUID();
6262
if(!this._uid){this._uid=Math.random()*10000000;localStorage.setItem("uid", this._uid);}
@@ -66,16 +66,22 @@ const BuggyTracker = function (d) {
6666
transaction_id: "T_"+cyrb53(this.getUID()+":"+oid),
6767
value: value,
6868
items: [{
69-
item_id: oid, price: value, item_category: category, item_list_id: list
69+
item_id: oid, price: value, item_category: category, item_list_name: list, item_brand: window.WEBSITE_SECTION
7070
}]
7171
});};
7272
this.handleEvent=function(e,link){link=e.target.closest('a');if(link && link.host != d.location.host) {
7373
var cid = link.getAttribute('data-content-path');
7474
var oid = cid || link.href;
7575
var value = link.getAttribute('ga-event-value')*1 || 0.15;
7676
if (localStorage.getItem(oid+":click")) value=0; else localStorage.setItem(oid+":click",1);
77-
var list=null;if(cid){list=whenceContent(d.referrer);}else{list=whenceLink(link)}
78-
if(value) this.sendEvent(oid,value,list,cid?'content-click':'link-click');
77+
var list=null,category=null;
78+
if(cid){
79+
list=whenceContent(d.referrer);
80+
category='Content';
81+
}else{
82+
category=linkType(link);
83+
}
84+
if(value) this.sendEvent(oid,value,list,category);
7985
}};
8086
d.addEventListener("click", this, {useCapture: true});
8187
d.addEventListener("contextmenu", this, {useCapture: true, passive: true});

0 commit comments

Comments
 (0)