基本上,我对编程很陌生,并被告知从Clojure和Hoplon (其中使用Clojurescript)开始。我试着把谷歌分析代码翻译成文本,我意识到我不知道该怎么做。有人能翻译一下这段代码吗?如果可能的话,我也非常希望能解释一下如何自己解决这个问题。我很感激能在这件事上得到任何帮助。(我已经搜索过了,我发现的只是一些翻译片段,但从来没有全部内容,所以我不知道如何实现。)
<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', 'GOOGLE-ANALYTICS-ID', 'auto');
ga('send', 'pageview');
</script>再次感谢你的帮助。
发布于 2015-09-07 21:28:48
您不需要对代码进行必要的移植(甚至更好)。这里作为一个示例,“今天的learndatalogtoday”项目的一个片段粘贴:
https://github.com/jonase/learndatalogtoday/blob/master/src/clj/learndatalogtoday/views.clj
(def google-analytics-string
"(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', 'UA-40247950-2', 'learndatalogtoday.org');
ga('send', 'pageview');")后来:
(html5
[:head
(include-css "/third-party/bootstrap/css/bootstrap.css")
(include-css "/style.css")
[:title "Learn Datalog Today!"]
[:script google-analytics-string]]https://stackoverflow.com/questions/32446017
复制相似问题