Skip to content

Commit

Permalink
Add twig templates
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Aug 31, 2020
1 parent 6af45f9 commit f26f4d1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/templates/SetonoTagBagGtag/config.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
{% if parameters|length > 0 %}
gtag('config', '{{ target }}', {{ parameters|json_encode(constant('JSON_THROW_ON_ERROR') b-or constant('JSON_PRETTY_PRINT') b-or constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_PRESERVE_ZERO_FRACTION') b-or constant('JSON_INVALID_UTF8_IGNORE')) }});
{% else %}
gtag('config', '{{ target }}');
{% endif %}
</script>
7 changes: 7 additions & 0 deletions src/templates/SetonoTagBagGtag/event.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
{% if parameters|length > 0 %}
gtag('event', '{{ event }}', {{ parameters|json_encode(constant('JSON_THROW_ON_ERROR') b-or constant('JSON_PRETTY_PRINT') b-or constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_PRESERVE_ZERO_FRACTION') b-or constant('JSON_INVALID_UTF8_IGNORE')) }});
{% else %}
gtag('event', '{{ event }}');
{% endif %}
</script>
6 changes: 6 additions & 0 deletions src/templates/SetonoTagBagGtag/library.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script async src="https://www.googletagmanager.com/gtag/js?id={{ id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
</script>
3 changes: 3 additions & 0 deletions src/templates/SetonoTagBagGtag/set.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
gtag('set', {{ parameters|json_encode(constant('JSON_THROW_ON_ERROR') b-or constant('JSON_PRETTY_PRINT') b-or constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_PRESERVE_ZERO_FRACTION') b-or constant('JSON_INVALID_UTF8_IGNORE')) }});
</script>

0 comments on commit f26f4d1

Please sign in to comment.