2016-09-19 15 views
0

Asciidoctorで生成されたすべてのHTMLページにGoogleアナリティクス(またはGoogleタグマネージャ)コードを追加するにはどうすればよいですか? an extensionがありますが、これはMavenリポジトリからは利用できません。私はasciidoctor-maven-pluginを使用しています。Asciidoctor:asciidoctor-maven-pluginを使用してすべてのHTMLページにGoogle Analyticsコードを追加する方法

答えて

0

ファイルが同じディレクトリにindex.adocの場合はindex-docinfo-footer.htmlを作成し、そのadocファイルには:docinfo:を追加してください。

とそのフッターファイルを入力します。

<script type="text/javascript"> 
dataLayer = [{'channel' : '{html-googleTagManagerChannel}', 'additional_tracking_code' : '{html-googleAnalyticsId}'}]; 
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 
})(window,document,'script','dataLayer','{html-googleTagManagerId}');</script> 
<noscript><iframe src="//www.googletagmanager.com/ns.html?id={html-googleTagManagerId}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> 

そして、あなたのpom.xmlにこのような何かを:

<plugin> 
     <groupId>org.asciidoctor</groupId> 
     <artifactId>asciidoctor-maven-plugin</artifactId> 
     <configuration> 
     <attributes> 
      <html-googleAnalyticsId>UA-123456789-1</html-googleAnalyticsId> 
      <html-googleTagManagerId>GTM-ABCDE</html-googleTagManagerId> 
      <html-googleTagManagerChannel>MyProject</html-googleTagManagerChannel> 
     </attributes> 
     </configuration> 
関連する問題