~xdavidwu/xdavidwu.link

9164c5053d6e05379468de3b8a1f510ceffc7d76 — Michael Rose 8 years ago 3bd495f
Add more analytics and commenting options
M _config.yml => _config.yml +14 -2
@@ 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           :


A _includes/analytics => _includes/analytics +12 -0
@@ 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 %}
\ No newline at end of file

A _includes/analytics-providers/custom => _includes/analytics-providers/custom +3 -0
@@ 0,0 1,3 @@
<!-- start custom analytics snippet -->

<!-- end custom analytics snippet -->
\ No newline at end of file

A _includes/analytics-providers/google => _includes/analytics-providers/google +11 -0
@@ 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>
\ No newline at end of file

A _includes/analytics-providers/google-universal => _includes/analytics-providers/google-universal +9 -0
@@ 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>
\ No newline at end of file

A _includes/comments => _includes/comments +14 -0
@@ 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 %}
\ No newline at end of file

A _includes/comments-providers/custom => _includes/comments-providers/custom +3 -0
@@ 0,0 1,3 @@
<!-- start custom comments snippet -->

<!-- end custom comments snippet -->
\ No newline at end of file

R _includes/disqus-comments => _includes/comments-providers/disqus +19 -19
@@ 1,22 1,22 @@
{% if site.disqus_shortname %}
<script type="text/javascript">
	/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
	var disqus_shortname = '{{ site.disqus_shortname }}';
{% 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 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>
  	/* * * 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 %}

A _includes/comments-providers/facebook => _includes/comments-providers/facebook +8 -0
@@ 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>
\ No newline at end of file

A _includes/comments-providers/google-plus => _includes/comments-providers/google-plus +2 -0
@@ 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>

M _includes/scripts => _includes/scripts +2 -16
@@ 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 %}

M _layouts/single.html => _layouts/single.html +11 -2
@@ 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>