extract analytics code out of HTML
This commit is contained in:
parent
fea92d1f6b
commit
ac0f719e21
|
@ -48,6 +48,10 @@ trait AssetHelper { self: I18nHelper =>
|
|||
s"""<script src="${staticUrl("javascripts/vendor/jquery.min.js")}"></script>"""
|
||||
}
|
||||
|
||||
val gaTag = Html {
|
||||
s"""<script src="${staticUrl("javascripts/ga.js")}"></script>"""
|
||||
}
|
||||
|
||||
val highchartsTag = cdnOrLocal(
|
||||
cdn = "//code.highcharts.com/4.1.4/highcharts.js",
|
||||
test = "window.Highcharts",
|
||||
|
|
|
@ -47,6 +47,6 @@
|
|||
userId: "null"
|
||||
});
|
||||
}
|
||||
@base.ga()
|
||||
@gaTag
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -213,6 +213,6 @@ withGtm: Boolean = false)(body: Html)(implicit ctx: Context)
|
|||
lichess_translations = @jsI18n()
|
||||
}
|
||||
}
|
||||
@if(withGtm) {@gtm()} else {@ga()}
|
||||
@if(withGtm) {@gtm()}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</div>
|
||||
@jsTag("vendor/chessground.min.js")
|
||||
@jsTagCompiled("puzzle.js")
|
||||
@base.ga()
|
||||
@gaTag
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -46,6 +46,6 @@
|
|||
userId: "null"
|
||||
});
|
||||
}
|
||||
@base.ga()
|
||||
@gaTag
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -23,6 +23,6 @@
|
|||
@jQueryTag
|
||||
@jsAt("javascripts/vendor/chessground.min.js", true, assetVersion)
|
||||
@jsAt("compiled/tv.js", true, assetVersion)
|
||||
@base.ga()
|
||||
@gaTag
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -23,7 +23,7 @@ for file in tv.js puzzle.js user.js coordinate.js; do
|
|||
fi
|
||||
done
|
||||
|
||||
orig="$SRC/jquery.fill.js $SRC/util.js $SRC/socket.js $LILA_AB_FILE $SRC/main.js"
|
||||
orig="$SRC/jquery.fill.js $SRC/util.js $SRC/socket.js $LILA_AB_FILE $SRC/main.js $SRC/ga.js"
|
||||
comp=$TARGET/lichess.js
|
||||
lilalog "Compiling $comp"
|
||||
uglifyjs -c -m -v $orig > $comp
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
@()
|
||||
<script>
|
||||
lichess.requestIdleCallback(function() {
|
||||
if (/.+\.lichess\.org/.test(document.domain)) {
|
||||
if (/.+\.lichess\.org/.test(document.domain) && !window.dataLayer) {
|
||||
(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)
|
||||
|
@ -10,4 +8,3 @@ ga('create', 'UA-7935029-3', 'auto');
|
|||
ga('send', 'pageview');
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Reference in a new issue