-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3280ef
commit a4212da
Showing
33 changed files
with
184 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,52 @@ | ||
#' Tracking tags for your app | ||
#' | ||
#' @param tag_template Tracking tag template | ||
#' @param tag_code If GA, the UA code. If GTM, the GTM code. | ||
#' | ||
#' tag_code depends on what tag_template is: | ||
#' | ||
#' \itemize{ | ||
#' \item ga: The UA code (UA-xxxxxx-x) | ||
#' \item gtm The GTM code (GTM-xxxxx) | ||
#' \item freeform The JS code | ||
#' } | ||
#' If you select a tag template, you can put UA-xxxx-x as tag_code | ||
#' | ||
#' @return JavaScript for tracking | ||
#' @export | ||
trackingTags <- function(tag_template = c("ga","gtm","freeform"), | ||
tag_code){ | ||
|
||
tag_template <- match.arg(tag_template) | ||
|
||
out <- switch(tag_template, | ||
ga = sprintf("<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','https://www.google-analytics.com/analytics.js','ga'); | ||
ga('create', '%s', 'auto'); | ||
ga('send', 'pageview'); | ||
</script>", tag_code), | ||
gtm = sprintf("<!-- Google Tag Manager --> | ||
<noscript><iframe src=\"//www.googletagmanager.com/ns.html?id=%s\" | ||
height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe></noscript> | ||
<script>(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','%s');</script> | ||
<!-- End Google Tag Manager -->", tag_code, tag_code), | ||
freeform = tag_code | ||
|
||
|
||
|
||
) | ||
|
||
shiny::HTML(out) | ||
|
||
} | ||
# #' Tracking tags for your app | ||
# #' | ||
# #' @param tag_template Tracking tag template | ||
# #' @param tag_code If GA, the UA code. If GTM, the GTM code. | ||
# #' | ||
# #' tag_code depends on what tag_template is: | ||
# #' | ||
# #' \itemize{ | ||
# #' \item ga: The UA code (UA-xxxxxx-x) | ||
# #' \item gtm The GTM code (GTM-xxxxx) | ||
# #' \item freeform The JS code | ||
# #' } | ||
# #' If you select a tag template, you can put UA-xxxx-x as tag_code | ||
# #' | ||
# #' @author Mark Edmondson, \email{m@@sunholo.com} | ||
# #' | ||
# #' @return JavaScript for tracking | ||
# #' @export | ||
# trackingTags <- function(tag_template = c("ga","gtm","freeform"), | ||
# tag_code){ | ||
# | ||
# tag_template <- match.arg(tag_template) | ||
# | ||
# out <- switch(tag_template, | ||
# ga = sprintf("<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','https://www.google-analytics.com/analytics.js','ga'); | ||
# | ||
# ga('create', '%s', 'auto'); | ||
# ga('send', 'pageview'); | ||
# | ||
# </script>", tag_code), | ||
# gtm = sprintf("<!-- Google Tag Manager --> | ||
# <noscript><iframe src=\"//www.googletagmanager.com/ns.html?id=%s\" | ||
# height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe></noscript> | ||
# <script>(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','%s');</script> | ||
# <!-- End Google Tag Manager -->", tag_code, tag_code), | ||
# freeform = tag_code | ||
# | ||
# | ||
# | ||
# ) | ||
# | ||
# shiny::HTML(out) | ||
# | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.