diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml index 93c037683..82c0a9b48 100644 --- a/.github/workflows/deploy-main.yml +++ b/.github/workflows/deploy-main.yml @@ -30,6 +30,7 @@ jobs: - run: firebase deploy --project civic-liker -f env: GA_TRACKING_ID: ${{ vars.GA_TRACKING_ID }} + AD_CONVERSION_ID: ${{ vars.AD_CONVERSION_ID }} STRIPE_PUBLIC_KEY: ${{ vars.STRIPE_PUBLIC_KEY }} CRISP_WEBSITE_ID: ${{ vars.CRISP_WEBSITE_ID }} SENTRY_DSN: ${{ vars.SENTRY_DSN }} diff --git a/.github/workflows/deploy-rinkeby.yml b/.github/workflows/deploy-rinkeby.yml index dee6c53cb..ccc2a8b6d 100644 --- a/.github/workflows/deploy-rinkeby.yml +++ b/.github/workflows/deploy-rinkeby.yml @@ -37,6 +37,7 @@ jobs: - run: firebase deploy --project civic-liker-develop -f env: GA_TRACKING_ID: ${{ vars.GA_TRACKING_ID }} + AD_CONVERSION_ID: ${{ vars.AD_CONVERSION_ID }} CRISP_WEBSITE_ID: ${{ vars.CRISP_WEBSITE_ID }} STRIPE_PUBLIC_KEY: ${{ vars.STRIPE_PUBLIC_KEY }} SENTRY_DSN: ${{ vars.SENTRY_DSN }} diff --git a/src/constant/index.js b/src/constant/index.js index c5ad3b542..bce58b95d 100644 --- a/src/constant/index.js +++ b/src/constant/index.js @@ -1,4 +1,4 @@ -export const { IS_TESTNET } = process.env; +export const { IS_TESTNET, AD_CONVERSION_ID } = process.env; export const TEST_MODE = process.env.NODE_ENV !== 'production' || process.env.CI; diff --git a/src/nuxt.config.js b/src/nuxt.config.js index 54b751f7b..5726dc2c4 100644 --- a/src/nuxt.config.js +++ b/src/nuxt.config.js @@ -11,7 +11,7 @@ const { CRISP_WEBSITE_ID, STRIPE_PUBLIC_KEY, GA_TRACKING_ID, - ADWORDS_TRACKING_ID, + AD_CONVERSION_ID, EXTERNAL_URL, } = process.env; @@ -22,7 +22,7 @@ const nuxtConfig = { CRISP_WEBSITE_ID, STRIPE_PUBLIC_KEY, GA_TRACKING_ID, - ADWORDS_TRACKING_ID, + AD_CONVERSION_ID, SITE_NAME, EXTERNAL_URL, }, diff --git a/src/pages/nft/claim/index.vue b/src/pages/nft/claim/index.vue index 369754df6..5792419fc 100644 --- a/src/pages/nft/claim/index.vue +++ b/src/pages/nft/claim/index.vue @@ -934,6 +934,7 @@ export default { price, currency: 'USD', isNFTBook: true, + paymentId: this.paymentId, }); items.forEach(item => { logPurchaseNFTBookEvent(this, { diff --git a/src/pages/nft/gift/index.vue b/src/pages/nft/gift/index.vue index d9fe49f89..6d1562086 100644 --- a/src/pages/nft/gift/index.vue +++ b/src/pages/nft/gift/index.vue @@ -139,6 +139,7 @@ export default { price, currency: 'USD', isNFTBook: true, + paymentId: this.paymentId, }); logPurchaseNFTBookEvent(this, { name: this.productName, diff --git a/src/plugins/gtag.client.js b/src/plugins/gtag.client.js index 145e0e719..e4426c09c 100644 --- a/src/plugins/gtag.client.js +++ b/src/plugins/gtag.client.js @@ -9,9 +9,6 @@ export default (ctx, inject) => { } = ctx; if (process.env.GA_TRACKING_ID) { const includes = []; - if (process.env.ADWORDS_TRACKING_ID) { - includes.push({ id: process.env.ADWORDS_TRACKING_ID }); - } Vue.use( VueGtag, { diff --git a/src/util/EventLogger.js b/src/util/EventLogger.js index 8b4131b5c..4349af754 100644 --- a/src/util/EventLogger.js +++ b/src/util/EventLogger.js @@ -1,4 +1,4 @@ -import { IS_TESTNET } from '../constant'; +import { IS_TESTNET, AD_CONVERSION_ID } from '../constant'; function hexString(buffer) { const byteArray = new Uint8Array(buffer); @@ -126,7 +126,7 @@ export function logTrackerEvent( export function logPurchaseFlowEvent( vue, event, - { txHash, price, currency, items, isNFTBook } + { txHash, price, currency, items, isNFTBook, paymentId } ) { try { if ( @@ -144,7 +144,7 @@ export function logPurchaseFlowEvent( } if (vue.$gtag) { vue.$gtag.event(event, { - transaction_id: txHash, + transaction_id: paymentId || txHash, value: price, currency, items: items.map(i => { @@ -159,6 +159,14 @@ export function logPurchaseFlowEvent( }; }), }); + if (event === 'purchase' && AD_CONVERSION_ID) { + vue.$gtag.event('conversion', { + send_to: AD_CONVERSION_ID, + value: price, + currency: 'USD', + transaction_id: paymentId || txHash, + }); + } } if (window.fbq && !IS_TESTNET) { const eventNameMapping = {