Feature/ecommerce gtag See merge request lilschool/site!408remotes/origin/feature/new-certs-1-10-19
commit
2b7a3a8dde
17 changed files with 339 additions and 93 deletions
@ -0,0 +1,12 @@ |
||||
from django import template |
||||
|
||||
register = template.Library() |
||||
|
||||
|
||||
@register.simple_tag(takes_context=True) |
||||
def same_url(context, **kwargs): |
||||
request = context.get('request') |
||||
args = request.GET.copy() |
||||
args.update(kwargs) |
||||
return '%s?%s' % (request.path, args.urlencode()) |
||||
|
||||
@ -1,12 +0,0 @@ |
||||
{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} |
||||
<div class="section"> |
||||
<div class="section__center center center_xs"> |
||||
<div class="done"> |
||||
<div class="done__title title">Вы успешно приобрели курс!</div> |
||||
<div class="done__foot"> |
||||
<a class="done__btn btn btn_md btn_stroke" href="{{ course.url }}">ПЕРЕЙТИ К КУРСУ</a> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% endblock content %} |
||||
@ -1,13 +0,0 @@ |
||||
{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} |
||||
<div class="section"> |
||||
<div class="section__center center center_xs"> |
||||
<div class="done"> |
||||
<div class="done__title title">Вы успешно приобрели подарочный сертификат!</div> |
||||
<div>Мы отправили письмо с сертификатом на вашу почту.</div> |
||||
<div class="done__foot"> |
||||
<a class="done__btn btn btn_md btn_stroke" href="{% url 'index' %}">СПАСИБО</a> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% endblock content %} |
||||
@ -0,0 +1,96 @@ |
||||
import $ from 'jquery'; |
||||
|
||||
$(document).ready(function () { |
||||
if(! window.LIL_STORE.user.id){ |
||||
return; |
||||
} |
||||
|
||||
if(window.LIL_STORE.urlIs(['courseBuy', 'schoolBuy', 'campBuy', 'giftCertificateBuy'])){ |
||||
if(window.LIL_STORE.urlIs(['schoolBuy', 'giftCertificateBuy'])){ |
||||
const $useBonuses = $('#use-bonuses-checkbox'); |
||||
$useBonuses.find('.switch__content').click(() => { |
||||
window.gtag('event', 'set_checkout_option', { |
||||
"checkout_step": 1, |
||||
"checkout_option": "use_bonuses", |
||||
"value": +!$useBonuses.find('input').prop('checked'), |
||||
}); |
||||
}); |
||||
$('#pay-with-bonuses').click(() => { |
||||
window.gtag('event', 'set_checkout_option', { |
||||
"checkout_step": 1, |
||||
"checkout_option": "use_bonuses", |
||||
"value": 1, |
||||
}); |
||||
}) |
||||
} |
||||
window.gtag('event', 'checkout_progress', { |
||||
"items": [window.LIL_STORE.data.gtagProduct], |
||||
}); |
||||
} |
||||
|
||||
if(window.LIL_STORE.urlIs(['courseBuySuccess', 'schoolBuySuccess', 'campBuySuccess', 'giftCertificateBuySuccess'])){ |
||||
window.gtag('event', 'checkout_progress', { |
||||
"items": [window.LIL_STORE.data.gtagProduct], |
||||
}); |
||||
window.gtag('event', 'purchase', window.LIL_STORE.data.gtagTransaction); |
||||
} |
||||
|
||||
if(window.LIL_STORE.urlIs('course')){ |
||||
const $btn = $('[data-popup=".js-popup-course-buy"]'); |
||||
$btn.click(() => { |
||||
window.gtag('event', 'begin_checkout', { |
||||
"items": [window.LIL_STORE.data.gtagProduct], |
||||
}); |
||||
}); |
||||
const $popup = $('.js-popup-course-buy'); |
||||
const $useBonusesSwitch = $popup.find('.buy__bonuses .switch__content'); |
||||
const $useBonusesInput = $popup.find('.buy__bonuses input'); |
||||
$useBonusesSwitch.click(() => { |
||||
window.gtag('event', 'set_checkout_option', { |
||||
"checkout_step": 1, |
||||
"checkout_option": "use_bonuses", |
||||
"value": +!$useBonusesInput.prop('checked'), |
||||
}); |
||||
}); |
||||
const $buyBtn = $popup.find('.buy__btn'); |
||||
$buyBtn.click(() => { |
||||
window.gtag('event', 'checkout_progress', { |
||||
"items": [window.LIL_STORE.data.gtagProduct], |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
if(window.LIL_STORE.urlIs('prices')){ |
||||
const $btns = $('.package__btn'); |
||||
$btns.click(function () { |
||||
const $this = $(this); |
||||
window.gtag('event', 'begin_checkout', { |
||||
"items": [{ |
||||
id: $this.data('package'), |
||||
name: 'Подписка на ' + +$this.data('duration') + ' месяцев', |
||||
category: 'Подписка', |
||||
brand: 'Lil.School', |
||||
quantity: 1, |
||||
price: +$this.data('price'), |
||||
}], |
||||
}); |
||||
}) |
||||
} |
||||
|
||||
if(window.LIL_STORE.urlIs('giftCertificates')){ |
||||
const $btns = $('.gift-certificates__buy-btn'); |
||||
$btns.click(function () { |
||||
const $this = $(this); |
||||
window.gtag('event', 'begin_checkout', { |
||||
"items": [{ |
||||
id: $this.data('gift-certificate'), |
||||
name: 'Подарочный сертификат на ' + +$this.data('price') + ' руб', |
||||
category: 'Подарочный сертификат', |
||||
brand: 'Lil.School', |
||||
quantity: 1, |
||||
price: +$this.data('price'), |
||||
}], |
||||
}); |
||||
}); |
||||
} |
||||
}); |
||||
Loading…
Reference in new issue