Adding analytic code
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 22
- Joined: Fri Aug 28, 2009 11:39 am
Adding analytic code
Hi
I have to add the following code in the dita pages. This is to identify the usage ratio of help files. Please let me know how can I add this code and how it could be generated on every build?
The code:
<!-- Start Code for Xiti Analytics -->
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/configuration-stat.js"></script>
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/stat.js"></script>
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/stat-dpl.js"></script>
<script type="text/javascript">
pageStatInjection();
</script>
<!-- End Code for Xiti Analytics -->
Regards
I have to add the following code in the dita pages. This is to identify the usage ratio of help files. Please let me know how can I add this code and how it could be generated on every build?
The code:
<!-- Start Code for Xiti Analytics -->
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/configuration-stat.js"></script>
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/stat.js"></script>
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/stat-dpl.js"></script>
<script type="text/javascript">
pageStatInjection();
</script>
<!-- End Code for Xiti Analytics -->
Regards
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Adding analytic code
Post by sorin_ristache »
Hi,
You should add the script elements in the template
from stylesheet
This template is called once for every DITA topic file processed by the DITA Map WebHelp transformation.
Regards,
Sorin
You should add the script elements in the template
Code: Select all
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
Code: Select all
[Oxygen-install-dir]/frameworks/dita/DITA-OT/plugins/com.oxygenxml.webhelp/xsl/dita2webhelpImpl.xsl
Regards,
Sorin
-
- Posts: 22
- Joined: Fri Aug 28, 2009 11:39 am
Re: Adding analytic code
Hi Sorin
Thank you for the reply. I am using Oxygen XML 9.3, so dita2webhelp is not available and the xsl which i am using in dita2xhtml.xsl. Is it possible to add the script in this file and run?
Regards
Thank you for the reply. I am using Oxygen XML 9.3, so dita2webhelp is not available and the xsl which i am using in dita2xhtml.xsl. Is it possible to add the script in this file and run?
Regards
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Adding analytic code
Post by sorin_ristache »
Hi Minnu,
In that case you should add your code in the same template
from the stylesheet
Regards,
Sorin
In that case you should add your code in the same template
Code: Select all
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
Code: Select all
[Oxygen-9.3-install-dir]/frameworks/dita/DITA-OT/xsl/xslhtml/dita2htmlImpl.xsl
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Adding analytic code
Post by sorin_ristache »
Hi,
Please open the following file for editing in the Oxygen application:
and locate the line that contains the text:
You have to insert your code after that line, so that the file contains after your modification:
Please note that you have to replace ${serverName}${contextPath} with the correct server name and path, because the HTML output file of the DITA Map XHTML transformation must contain a real Web address from where the JavaScript files which you want to add with the <script> elements (configuration-stat.js, stat.js. etc.) can really be loaded by a Web browser (IE, Firefox, Chrome, etc). After you save the dita2htmlImpl.xsl file just run the transformation DITA Map XHTML on your DITA map file for creating the output HTML files from your DITA XML topics.
Regards,
Sorin
Please open the following file for editing in the Oxygen application:
Code: Select all
[Oxygen-9.3-install-dir]/frameworks/dita/DITA-OT/xsl/xslhtml/dita2htmlImpl.xsl
Code: Select all
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
Code: Select all
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
<!-- Start Code for Xiti Analytics -->
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/configuration-stat.js"></script>
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/stat.js"></script>
<script type="text/javascript" src="//${serverName}${contextPath}/js/xiti/stat-dpl.js"></script>
<script type="text/javascript">
pageStatInjection();
</script>
<!-- End Code for Xiti Analytics -->
</xsl:template>
Regards,
Sorin
-
- Posts: 22
- Joined: Fri Aug 28, 2009 11:39 am
Re: Adding analytic code
Hi Sorin
I have added the code as follows in the dita2htmlImpl.xsl file, but it didn't work!
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
<xsl:template name="gen-user-scripts">
<xsl:apply-templates select="." mode="gen-user-scripts"/>
</xsl:template>
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
<!-- Start Code for Xiti Analytics -->
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript">
pageStatInjection();
</script>
<!-- End Code for Xiti Analytics -->
<!-- to customize: copy this to your override transform, add the content you want. -->
<!-- It will be placed before the ending HEAD tag -->
<!-- see (or enable) the named template "script-sample" for an example -->
</xsl:template>
Please let me know if there is anything wrong
I have added the code as follows in the dita2htmlImpl.xsl file, but it didn't work!
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
<xsl:template name="gen-user-scripts">
<xsl:apply-templates select="." mode="gen-user-scripts"/>
</xsl:template>
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
<!-- Start Code for Xiti Analytics -->
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript">
pageStatInjection();
</script>
<!-- End Code for Xiti Analytics -->
<!-- to customize: copy this to your override transform, add the content you want. -->
<!-- It will be placed before the ending HEAD tag -->
<!-- see (or enable) the named template "script-sample" for an example -->
</xsl:template>
Please let me know if there is anything wrong
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Adding analytic code
Post by sorin_ristache »
Hi Minnu,
The following lines should be removed from dita2htmlImpl.xsl:
so that only the following fragment added by you remains in the dita2htmlImpl.xsl file:
In your initial request you said that you wanted to include also the scripts stat.js and stat-dpl.js but in your later code you did not include it as you did for configuration-stat.js. Do you still need stat.js and stat-dpl.js? If yes please include them in the same way as with configuration-stat.js.
After this modification please check if each HTML page generated by the Oxygen transformation contains the above <script> elements which include your JavaScript code in the Web page. After that you should check if your code is ever executed with some JavaScript debugging techniques. Do you have experience with running and debugging JavaScript code?
Regards,
Sorin
The following lines should be removed from dita2htmlImpl.xsl:
Minnu wrote:Code: Select all
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
<xsl:template name="gen-user-scripts">
<xsl:apply-templates select="." mode="gen-user-scripts"/>
</xsl:template>
so that only the following fragment added by you remains in the dita2htmlImpl.xsl file:
Please note in the code above that I removed the two duplicate inclusions of configuration-stat.js because it is enough to include it only once.Code: Select all
<xsl:template match="/|node()|@*" mode="gen-user-scripts">
<!-- Start Code for Xiti Analytics -->
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/configuration-stat.js"></script>
<script type="text/javascript">
pageStatInjection();
</script>
<!-- End Code for Xiti Analytics -->
<!-- to customize: copy this to your override transform, add the content you want. -->
<!-- It will be placed before the ending HEAD tag -->
<!-- see (or enable) the named template "script-sample" for an example -->
</xsl:template>
In your initial request you said that you wanted to include also the scripts stat.js and stat-dpl.js but in your later code you did not include it as you did for configuration-stat.js. Do you still need stat.js and stat-dpl.js? If yes please include them in the same way as with configuration-stat.js.
After this modification please check if each HTML page generated by the Oxygen transformation contains the above <script> elements which include your JavaScript code in the Web page. After that you should check if your code is ever executed with some JavaScript debugging techniques. Do you have experience with running and debugging JavaScript code?
Regards,
Sorin
-
- Posts: 22
- Joined: Fri Aug 28, 2009 11:39 am
Re: Adding analytic code
Hi Sorin
I do not have experience with javascript debugging. Following your instructions, I tried running the script. But, in the ouput html file the script gets closed inside the .js. The script which I have given in the ditaimpl.xsl file is
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript">
pageStatInjection();
</script>
In the output html files, it is generated as:
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "/><script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "/><script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "/><script type="text/javascript">
pageStatInjection();
</script>
So, I was told that the .js file is not calling. Please help
Regards
I do not have experience with javascript debugging. Following your instructions, I tried running the script. But, in the ouput html file the script gets closed inside the .js. The script which I have given in the ditaimpl.xsl file is
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript">
pageStatInjection();
</script>
In the output html files, it is generated as:
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "/><script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "/><script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "/><script type="text/javascript">
pageStatInjection();
</script>
So, I was told that the .js file is not calling. Please help
Regards
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Adding analytic code
Post by sorin_ristache »
Hi,
Please see my previous post above where I suggested how you should include your JavaScript files in the output HTML pages. What are the JavaScript files that you need to include in the HTML pages? Did you test that JavaScript code in any way before including it in the HTML pages for making sure that it works correctly?
I do not know what your JavaScript code should do but: if the JavaScript code does not do what you want and you are not sure why then you will need to debug your JavaScript code to see where it does not work as expected. This is why you will need to work together with someone at your company who knows how to debug the JavaScript code for helping you to fix the code in your HTML pages.
Regards,
Sorin
I do not understand: do you mean that the JavaScript code ends unexpectedly, or that the JavaScript code is not called when it should be called?Minnu wrote:in the ouput html file the script gets closed inside the .js.
. . .
So, I was told that the .js file is not calling.
As I said above in this discussion you do not need to duplicate the inclusion of a JavaScript file. Why do you include configuration-stat.js 3 times in an HTML page?Minnu wrote:The script which I have given in the ditaimpl.xsl file is
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript" src="http://designportal.apc.com/js/xiti/con ... "></script>
<script type="text/javascript">
pageStatInjection();
</script>
Please see my previous post above where I suggested how you should include your JavaScript files in the output HTML pages. What are the JavaScript files that you need to include in the HTML pages? Did you test that JavaScript code in any way before including it in the HTML pages for making sure that it works correctly?
I do not know what your JavaScript code should do but: if the JavaScript code does not do what you want and you are not sure why then you will need to debug your JavaScript code to see where it does not work as expected. This is why you will need to work together with someone at your company who knows how to debug the JavaScript code for helping you to fix the code in your HTML pages.
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service