Skip to content

Commit

Permalink
Merge pull request #755 from PecanProject/GA4
Browse files Browse the repository at this point in the history
updated google analytics code
  • Loading branch information
robkooper authored Jul 14, 2024
2 parents 7165d63 + 5c6e9c0 commit 44b09e2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 36 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ ENV LOCAL_SERVER=99 \
PGDATABASE=postgres \
BETYUSER=bety \
BETYPASSWORD=bety \
BETYDATABASE=bety
BETYDATABASE=bety \
GOOGLE_ANALYTICS_ID=G-0000000000

# Install dependencies
RUN apt-get update \
Expand Down
19 changes: 8 additions & 11 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,15 @@
<%#= stylesheet_link_tag 'themes/default' %>
<%#= stylesheet_link_tag 'themes/alphacube' %>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30952394-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
<!-- Google Analytics (G4) tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= CONFIG[:google_analytics_id] %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '<%= CONFIG[:google_analytics_id] %>');
</script>

<!-- Maintain the order of the following CSS until we can gut the "scaffold" CSS -->
<!-- Old CSS -->
<%#= stylesheet_link_tag "scaffold" %>
Expand Down
23 changes: 8 additions & 15 deletions app/views/layouts/fullscreen.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@
<% end %>

<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no" />
<!-- Google Analytics (GA5) tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= CONFIG[:google_analytics_id] %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=true"></script>
<% end %>

<meta name="verify-v1" content="T7Z0mdC+KbUOu+J0CJ6oBySKYz1WUJQJLH0BOtUn1QA=" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30952394-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

gtag('config', '<%= CONFIG[:google_analytics_id] %>');
</script>

</head>
<body style="height:100%">
<%= yield %>
Expand Down
4 changes: 3 additions & 1 deletion config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ site_identification_markup: "<strong>PEcAn</strong>db <small><strong>The PEcAn</


# Footer

footer_background_image_file: "https://energybiosciencesinstitute.org/wp-content/themes/ebi/assets/logo.png"

# google analyitics
google_analytics_id: <%= ENV["GOOGLE_ANALYTICS_ID"] || 'G-0000000000' %>

## Contact Information
admin_phone: "(000) 000-0000"
admin_email: "[email protected]" # a test
Expand Down
8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
# BETY rails frontend to the database
bety:
Expand All @@ -11,15 +9,16 @@ services:
environment:
- UNICORN_WORKER_PROCESSES=1
- SECRET_KEY_BASE=thisisnotasecret
- GOOGLE_ANALYTICS_ID=G-0000000000
depends_on:
- postgres
restart: unless-stopped

# postgresql + postgis to hold all the data
postgres:
image: postgis/postgis:12-3.3
env:
POSTGRES_PASSWORD: bety
environment:
POSTGRES_PASSWORD: postgres
networks:
- bety
#ports:
Expand All @@ -33,4 +32,3 @@ networks:

volumes:
postgres:

11 changes: 8 additions & 3 deletions public/UI_redesign/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,15 @@ <h3><strong>Translate</strong> Page</h3>
});
</script>

<!-- http://mths.be/aab -->

<!-- Google Anaytics (GA4) tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2PN4PE3MT2"></script>
<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']]; // Change UA-XXXXX-X to be your site's ID
//(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'));
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-2PN4PE3MT2');
</script>

<script>
Expand Down

0 comments on commit 44b09e2

Please sign in to comment.