-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ecomerce tracking to complete order #92
Comments
This looks good, but do you mean to have this as default in the project? It would make sense to have this as an option. Makes sense ? |
To anyone interested in this, I finally ended up with a bit different code, which works for me and I also added FB Pixel code: {% load i18n %}
{% block analytics_head %}
{{ block.super }}
{% if object.get_status_display == 'completed' %}
<script>
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '{{ object.id }}',
'affiliation': 'Plan purchase',
'revenue': '{{ object.amount }}',
'tax': '{{ object.tax_total }}'
});
ga('ecommerce:addItem', {
'id': '{{ object.id }}',
'name': '{{ object.name }}',
'sku': 'P{{ object.plan.id }}',
'price': '{{ object.amount }}',
'category': 'Subscription plan',
'tax': '{{ object.tax_total }}',
'quantity': '1'
});
ga('ecommerce:send');
</script>
<script>
fbq('track', 'Purchase', {
value: {{ object.amount }},
currency: 'USD',
content_ids: '{{ object.id }}',
content_type: 'plan',
});
</script>
{% endif %}
{% endblock %} Note: The current code can lead to duplicate reports if the user renew the payment confirmation page. @Alir3z4 Turning this on by default would be definitely bad thing to do. But I don't quite understand your solution. I think, that it would be nice to offer users code that is included in |
I wanted to set up ecomerce tracking for Google Analytics for my plans. All I had to do is override the
plans/order_detail.html
template with the following code. Do you have interest to include this in this project?The text was updated successfully, but these errors were encountered: