Skip to content

Commit

Permalink
Make user_id available in the GTM data layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Oct 24, 2024
1 parent 644d6df commit 1fb240e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/views/application/_google_tag_manager.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<script>
window.dataLayer = window.dataLayer || [];
<% if current_user %>
dataLayer.push({
'user_id': '<%= current_user.id %>'
})
<% end %>
</script>
<%# TODO: Extract GTM code into configuration %>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
Expand Down

0 comments on commit 1fb240e

Please sign in to comment.