Add more analytics and commenting options

This commit is contained in:
Michael Rose 2016-03-07 11:29:35 -05:00
parent 3bd495f1d4
commit 9164c5053d
13 changed files with 111 additions and 42 deletions

View file

@ -24,12 +24,24 @@ facebook:
username : &facebook "site_facebook"
app_id :
publisher :
disqus_shortname : "mmistakes-dev" # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
comments:
provider : false # false (default), "disqus", "facebook", "google-plus", custom"
disqus:
shortname : "mmistakes-dev" # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
facebook:
# https://developers.facebook.com/docs/plugins/comments
appid :
num_posts : # 5 (default)
width : # 580 (default)
colorscheme : # "light" (default), "dark"
google_site_verification :
bing_site_verification :
alexa_site_verification :
yandex_site_verification :
google_analytics : # Universal Analytics tracking ID
analytics:
provider : false # false (default), "google", "google-universal", "custom"
google:
tracking_id : "UA-123456-7"
google_ad_client :
google_ad_slot :

12
_includes/analytics Normal file
View file

@ -0,0 +1,12 @@
{% if site.analytics.provider and page.analytics != false %}
{% case site.analytics.provider %}
{% when "google" %}
{% include /analytics-providers/google %}
{% when "google-universal" %}
{% include /analytics-providers/google-universal %}
{% when "custom" %}
{% include /analytics-providers/custom %}
{% endcase %}
{% endif %}

View file

@ -0,0 +1,3 @@
<!-- start custom analytics snippet -->
<!-- end custom analytics snippet -->

View file

@ -0,0 +1,11 @@
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ site.analytics.google.tracking_id }}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

View file

@ -0,0 +1,9 @@
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', {{ site.analytics.google.tracking_id }}', 'auto');
ga('send', 'pageview');
</script>

14
_includes/comments Normal file
View file

@ -0,0 +1,14 @@
{% if site.comments.provider and page.comments %}
{% case site.comments.provider %}
{% when "disqus" %}
{% include /comments-providers/disqus %}
{% when "facebook" %}
{% include /comments-providers/facebook %}
{% when "google-plus" %}
{% include /comments-providers/google-plus %}
{% when "custom" %}
{% include /comments-providers/custom %}
{% endcase %}
{% endif %}

View file

@ -0,0 +1,3 @@
<!-- start custom comments snippet -->
<!-- end custom comments snippet -->

View file

@ -0,0 +1,22 @@
{% if site.comments.disqus.shortname %}
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = '{{ site.comments.disqus.shortname }}';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{% endif %}

View file

@ -0,0 +1,8 @@
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5{% if site.comments.facebook.appid %}&appId={{ site.comments.facebook.appid }}{% endif %}";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

View file

@ -0,0 +1,2 @@
<script async type="text/javascript" src="//apis.google.com/js/plusone.js?callback=gpcb"></script>
<noscript>Please enable JavaScript to view the <a href="https://plus.google.com/">comments powered by Google+.</a></noscript>

View file

@ -1,22 +0,0 @@
{% if site.disqus_shortname %}
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = '{{ site.disqus_shortname }}';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{% endif %}

View file

@ -2,19 +2,5 @@
<script>window.jQuery || document.write('<script src="{{ base_path }}/assets/js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
<script src="{{ base_path }}/assets/js/scripts.min.js"></script>
{% if site.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
{% if page.comments %}
{% include disqus-comments %}
{% endif %}
{% include analytics %}
{% include comments %}

View file

@ -32,8 +32,17 @@ layout: default
</footer>
</div><!-- /.article-wrap -->
{% if site.disqus_shortname and page.comments %}
<section id="disqus_thread"></section><!-- /#disqus_thread -->
{% if site.comments.provider and page.comments %}
{% case site.comments.provider %}
{% when "disqus" %}
<section id="disqus_thread"></section>
{% when "facebook" %}
<section class="fb-comments" data-href="{{ base_path }}{{ page.url }}" data-num-posts="{{ site.comments.facebook.num_posts | default: 5 }}" data-width="{{ site.comments.facebook.width | default: 580 }}" data-colorscheme="{{ site.comments.facebook.colorscheme | default: 'light' }}"></section>
{% when "google-plus" %}
<section class="g-comments" data-href="{{ base_path }}{{ page.url }}" data-first_party_property="BLOGGER" data-view_type="FILTERED_POSTMOD">Loading Google+ Comments ...</section>
{% when "custom" %}
<section id="comments"></section>
{% endcase %}
{% endif %}
</article>