Skip to content

Commit

Permalink
Merge pull request #1257 from Ky7m/add_application_insights_analytics…
Browse files Browse the repository at this point in the history
…_support

Add Application Insights analytics support
  • Loading branch information
iissnan committed Nov 15, 2016
2 parents a12fb44 + 0d363d6 commit 2db2023
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ mathjax:
# CNZZ count
#cnzz_siteid:

# Application Insights
# See https://azure.microsoft.com/en-us/services/application-insights/
# application_insights:

# Make duoshuo show UA
# user_id must NOT be null when admin_enable is true!
Expand Down
1 change: 1 addition & 0 deletions layout/_scripts/third-party/analytics.swig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
{% include 'analytics/baidu-analytics.swig' %}
{% include 'analytics/tencent-analytics.swig' %}
{% include 'analytics/cnzz-analytics.swig' %}
{% include 'analytics/application-insights.swig' %}
11 changes: 11 additions & 0 deletions layout/_scripts/third-party/analytics/application-insights.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% if theme.application_insights %}
<script type="text/javascript">
var appInsights=window.appInsights||function(config){
function i(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s="AuthenticatedUserContext",h="start",c="stop",l="Track",a=l+"Event",v=l+"Page",y=u.createElement(o),r,f;y.src=config.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js";u.getElementsByTagName(o)[0].parentNode.appendChild(y);try{t.cookie=u.cookie}catch(p){}for(t.queue=[],t.version="1.0",r=["Event","Exception","Metric","PageView","Trace","Dependency"];r.length;)i("track"+r.pop());return i("set"+s),i("clear"+s),i(h+a),i(c+a),i(h+v),i(c+v),i("flush"),config.disableExceptionTracking||(r="onerror",i("_"+r),f=e[r],e[r]=function(config,i,u,e,o){var s=f&&f(config,i,u,e,o);return s!==!0&&t["_"+r](config,i,u,e,o),s}),t
}({
instrumentationKey:"{{ theme.application_insights }}"
});
window.appInsights=appInsights;
appInsights.trackPageView();
</script>
{% endif %}

0 comments on commit 2db2023

Please sign in to comment.