diff --git a/README.md b/README.md index 526f21d6ec7..fc7fc7c6641 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,12 @@ docker run -d -p 80:8080 -e BASE_URL=/swagger-editor swaggerapi/swagger-editor docker run -d -p 80:80 -e PORT=80 swaggerapi/swagger-editor ``` +* You can specify Google Tag Manager ID via `GTM` variable for tracking the usage of the swagger-editor. + +``` +docker run -d -p 80:8080 -e GTM=GTM-XXXXXX swaggerapi/swagger-editor +``` + You can also customize the different endpoints used by the Swagger Editor with the following environment variables. For instance, this can be useful if you have your own Swagger generator server: Environment variable | Default value diff --git a/docker-run.sh b/docker-run.sh index 26a32f58c25..54f54773d22 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -59,6 +59,14 @@ if [[ "${URL_OAS3_GENERATOR}" ]]; then fi fi +## Adding Google Tag Manager if GTM is set +if [[ "${GTM}" ]]; then + GTM_SCRIPT="" + GTM_NOSCRIPT="" + sed -i "s~~$GTM_SCRIPT~" $INDEX_FILE + sed -i "s~~$GTM_NOSCRIPT~" $INDEX_FILE +fi + ## Gzip after replacements #find /usr/share/nginx/html/ -type f -regex ".*\.\(html\|js\|css\)" -exec sh -c "gzip < {} > {}.gz" \; # diff --git a/index.html b/index.html index e0cfe672a45..c24f6837afd 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,7 @@