Merge branch 'fb-gtag-update' of https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0 into vapor/staging

# Conflicts:
#	resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue
This commit is contained in:
Edmond Lang
2025-12-10 00:16:50 +08:00
4 changed files with 57 additions and 1 deletions
@@ -169,6 +169,7 @@
</template>
<script>
import registrationFormValidation from '../../../general/mixins/accounts/validation/registrationFormValidation'
import { track } from '../../../utils/tracking';
export default {
data() {
return {
@@ -207,6 +208,17 @@
const urlParams = new URLSearchParams(window.location.search);
const tracking = urlParams.get('tracking');
this.step === 2 ? this.submit(this.route('api.account.registration.register') + (tracking ? '?tracking=' + tracking : ''), 'post', 'registrationSection', false, false) : this.changeStep('next');
},
successHandler(response){
// fire to gtag manager for fb pixel tracking: CompleteRegistration
track('exchange_complete_registration', {
content_name: this.parameters.type === 1 ? 'Company' : 'Personal',
currency: 'MYR'
});
// Call parent success handler logic from authenticationHandler mixin
this.formHandler('');
this.$store.dispatch('userAuthentication', {access_token: response.payload.access_token, redirect_url: response.payload.redirect_url});
}
},
mixins: [registrationFormValidation]
@@ -11,6 +11,7 @@
<script>
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
import { track } from '../../../utils/tracking';
export default {
props:{
order_reference_no: {
@@ -26,6 +27,12 @@
},
methods: {
submitForm(){
// fire to gtag manager for fb pixel tracking: AddToCart — fired when the user clicks Confirm Order (user intent, OK even if API fails)
track('exchange_add_to_cart', {
value: this.data.amount,
currency: 'MYR'
});
this.parameters = {
company_id: this.data.company.id,
type: this.data.type,
@@ -42,6 +49,13 @@
this.submit(route('api.booking.create'), 'post', this.section, true, true)
},
successHandler(response){
// fire to gtag manager for fb pixel tracking: InitiateCheckout — booking created
track('exchange_checkout', {
value: this.data.amount,
currency: 'MYR',
booking_id: response.payload.data.marking
});
window.location.href = this.route('booking.details', response.payload.data.marking)
}
+13
View File
@@ -0,0 +1,13 @@
// resources/assets/vue/utils/tracking.js
export function track(event, payload = {}) {
if (typeof window === 'undefined') return;
// console.log('tracking', event, payload);
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event,
...payload,
});
}
@@ -103,4 +103,21 @@
</div>
</div>
@endsection
@endsection
@push('scripts')
@if($status === 2 && isset($transaction) && $transaction)
<script>
(function() {
// fire to gtag manager for fb pixel tracking: exchange_purchase
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'exchange_purchase',
transaction_id: @json($transaction->payment_reference ?? ''),
value: {{ (float)($transaction->amount ?? 0) }},
currency: 'MYR'
});
})();
</script>
@endif
@endpush