-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding analytics to experiment html page
- Loading branch information
Showing
5 changed files
with
128 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!-- Google Tag Manager (noscript) --> | ||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W59SWTR" | ||
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> | ||
<!-- End Google Tag Manager (noscript) --> |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!--Google Tag Manager--> | ||
<script> | ||
window.dataLayer = [{ | ||
'labName': '{{LAB_NAME}}', | ||
'discipline': '{{BROAD_AREA}}', | ||
'college': '{{COLLEGE_NAME}}', | ||
'phase': '{{PHASE}}', | ||
'expName': '{{EXP_NAME}}', | ||
'expShortName': '{{EXP_SHORT_NAME}}' | ||
}]; | ||
|
||
(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= | ||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
})(window,document,'script','dataLayer','GTM-W59SWTR'); | ||
</script> | ||
<!--End Google Tag Manager--> |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
root=expbuilds | ||
chmod -R u+rwx $root | ||
head_snippet=$(tr -d '\n' < analytics/headSnippet) | ||
body_snippet=$(tr -d '\n' < analytics/bodySnippet) | ||
topic_map=$(tr -d '\n' < analytics/topic_config.json) | ||
function insert_analytics_snippets () { | ||
fn=$1 | ||
|
||
if [ $(grep -c "window.dataLayer" $fn) == 0 ] | ||
then | ||
sed -i "s@<head>@<head>${head_snippet//&/\\&}@" $fn | ||
sed -i "s@<body>@<body>${body_snippet//&/\\&}@" $fn | ||
else | ||
echo "analytics script already present." | ||
echo | ||
fi | ||
} | ||
# get the list of html pages | ||
pages=$(find $root -not -path "*/themes/*" -type f -name "*.html") | ||
|
||
# insert snippets in all html pages | ||
for p in $pages | ||
do | ||
#echo $p | ||
insert_analytics_snippets $p | ||
done | ||
|
||
find $root -name "*.html" -exec sed -i "s@TOPIC_MAP@$topic_map@" {} \; |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
root=build/docs | ||
chmod -R u+rwx $root | ||
head_snippet=$(tr -d '\n' < analytics/headSnippet) | ||
body_snippet=$(tr -d '\n' < analytics/bodySnippet) | ||
topic_map=$(tr -d '\n' < analytics/topic_config.json) | ||
function insert_analytics_snippets () { | ||
fn=$1 | ||
|
||
if [ $(grep -c "window.dataLayer" $fn) == 0 ] | ||
then | ||
sed -i "s@<head>@<head>${head_snippet//&/\\&}@" $fn | ||
sed -i "s@<body>@<body>${body_snippet//&/\\&}@" $fn | ||
else | ||
echo "analytics script already present." | ||
echo | ||
fi | ||
} | ||
# get the list of html pages | ||
pages=$(find $root -not -path "*/themes/*" -type f -name "*.html") | ||
|
||
# insert snippets in all html pages | ||
for p in $pages | ||
do | ||
#echo $p | ||
insert_analytics_snippets $p | ||
done | ||
|
||
find $root -name "*.html" -exec sed -i "s@TOPIC_MAP@$topic_map@" {} \; |
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