Skip to content

Commit

Permalink
Adding code for debugging (#2440)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
annagav and pre-commit-ci[bot] authored Nov 5, 2024
1 parent 02fb5a2 commit 228c138
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
31 changes: 25 additions & 6 deletions main/templates/partials/gtm_body.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
{% if APIKEYS.GTM_TRACKING_ID %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ APIKEYS.GTM_TRACKING_ID }}"></script>
{# <script async src="https://www.googletagmanager.com/gtag/js?id={{ APIKEYS.GTM_TRACKING_ID }}"></script>#}
{# <script>#}
{# window.dataLayer = window.dataLayer || [];#}
{# function gtag(){dataLayer.push(arguments);}#}
{# gtag('js', new Date());#}
{##}
{# gtag('config', '{{ APIKEYS.GTM_TRACKING_ID }}');#}
{# </script>#}
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ APIKEYS.GTM_TRACKING_ID }}');
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ event: 'purchase', ecommerce: {
transaction_id: 'abc123', // order or transaction id
value: 50.00, // total purchase value excluding discounts
tax: 0.00,
shipping: 0.00,
currency: 'USD',
coupon: '5off', // coupon code the user used. leave blank if none
items: [
{
item_id: 'MITxT+14.100x', // course ID
item_name: 'Microeconomics', //course name
affiliation: 'MITx Online', coupon: '5off', discount: 5.00, item_category: "MicroMasters", // course category if possible
price: 50.00, quantity: 1
}
]
}});
</script>
{% endif %}
20 changes: 15 additions & 5 deletions main/templates/partials/gtm_head.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{% if APIKEYS.GTM_TRACKING_ID %}
<script>(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','{{ APIKEYS.GTM_TRACKING_ID }}');</script>
{# <script>(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','{{ APIKEYS.GTM_TRACKING_ID }}');</script>#}

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ APIKEYS.GTM_TRACKING_ID }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ APIKEYS.GTM_TRACKING_ID }}');
</script>
{% endif %}

0 comments on commit 228c138

Please sign in to comment.