Skip to content
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

Transactions are not being reflected on GA dashboard #175

Open
andirsun opened this issue Jan 6, 2022 · 3 comments
Open

Transactions are not being reflected on GA dashboard #175

andirsun opened this issue Jan 6, 2022 · 3 comments

Comments

@andirsun
Copy link

andirsun commented Jan 6, 2022

Hi, I want to track ecommerce purchases for my wesite, I want to send purchases via visitor.transaction() but the data is not reflected in the dashboard.
Just for testing porpuses I am sending the data as a normal event and this is working properly, any idea?

This is the code I am using

export const accountUpgradeEvent = async (
  data: IAccountUpgradeEvent
): Promise<void> => {
  try {
    const visitor = ua(
      GOOGLE_ANALYTICS_ACCOUNT_ID,
      data.user.lastGoogleAnalyticsUserId || '',
      { uid: data.user.hash }
    )
    visitor.set('uid', data.user.hash)

    const checkoutService = new CheckoutService()

    const { user, coupon, seats, paymentId, stripePriceId, productHash } = data

    const eventData: AccountUpgradeEventData = {
      coupon,
      tool: 'web',
      transactionId: paymentId,
      subscriptionType: user.isLegacyUser() ? 'legacy' : 'paid',
      legacyLicense: user.getLegacyLicense(),
      seats,
      planAmount: await checkoutService.getPlanPrice(stripePriceId),
      planFrecuency: await checkoutService.getPlanFrecuency(stripePriceId),
      planName: await checkoutService.getPlanName(productHash),
    }

    if (eventData.planAmount === 0) {
      logger.error(
        `Google Analytics: planAmount is 0 on accountUpgradeEvent for transactionId ${paymentId}`
      )
    }

    visitor
      .transaction({
        ti: eventData.transactionId,
        tr: eventData.planAmount,
      })
      .item({
        ip: eventData.planAmount,
        in: `${eventData.planName}-${eventData.planFrecuency}`,
        ic: productHash,
        iq: 1,
      })
      .send()
    visitor
      .event({
        ec: 'Purchases',
        ea: 'Account Upgrade',
        el: 'Account Upgrade',
        ev: eventData.planAmount,
      })
      .send()
    console.log('llegue a mandarlo')
  } catch (error) {
    console.log(`Google Analytics: accountUpgradeEvent error: ${error}`)
    logger.error(`Google Analytics: accountUpgradeEvent error: ${error}`)
  }
}

Events are working normally

Screenshot from 2022-01-06 12-17-11

Transactions are not working (I have activated ecomercer for my property)

Screenshot from 2022-01-06 12-17-34

@andirsun andirsun changed the title Transaction is not reflected being reflected on GA dashboard Transactions are not being reflected on GA dashboard Jan 6, 2022
@christianblandford
Copy link

Make sure you aren't running an ad blocked anywhere in the chain... check the browser and your router, etc...

@MatiusRock1
Copy link

@andirsun I have the same problem as you, you closed the report but the solution was not indicated, could you help me with a solution please.

Greetings

@andirsun
Copy link
Author

I was not able to fix it and data was not accurated, so I recommend you to use frontend library or cloud instance on google cloud.

@andirsun andirsun reopened this Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants