danwilson / google-analytics-plugin

Cordova (PhoneGap) Plugin to connect to the native Google's Universal Analytics SDK 3.0
MIT License
693 stars 500 forks source link

Does this plugin work with the new Google Analytics 4? #589

Open peter-rosendahl opened 3 years ago

peter-rosendahl commented 3 years ago

I'm facing challenges implementing Google Analytics tracking on my Ionic 5/Cordova app.

In the documentation of this plugin I can see that the plugin requires a UA-xxxxxxxxx-x ID. But with the new version 4 (rolled out in october 2020), Google Analytics have split up the streaming procedures between web, Android and iOS, meaning that the above ID only works for websites - they even declare in their documentation for setting up Google Analytics that their Universal Analytics property no longer supports app measurement. So it seems that if you're creating a Google analytics property today, it won't work with the original procedure that is described in this plugin's documentation.

So, my question is this: Is there a workaround for this plugin to work with this new version of Google Analytics? Or is it being developed now as we speak?

Being a newcomer to this plugin, it really does look fascinating with all of its possibilities, so I hope (and pray) that this plugin will live on and prosper through challenges like this one.

carabationut commented 3 years ago

@peter-rosendahl I am in the same situation as you are right now. I have a project ready for production and looked all over the web, like everywhere and test all kinds of stuff, but with no luck. There is someone who found a solution on this?

I know that the version for cordova/capacitor is kind of the same on ionic v5, so pls, who has a working version, could you lend a hand with an update and simple/basic example with init and page views and events?

We will be forever in debt to you and we will send you at least a beer.

Thank you, John.

pjschrock commented 2 years ago

After spending a day looking into this, it appears that developers have not informed us that Google Analytics no longer works with this plugin for apps. It sure would be nice if someone would just add a note here so we don't burn so much time. If you want to use google analytics now you must do so by setting up a firebase app, use firebase analytics, and then connect your firebase account to google analytics. I haven't figured out how to do all this yet. It involves setting up separate config files for ios and android then firebase will tell you where to place it in your project and what settings files to change. Then you can get a different plugin that should work... we will see...

ravimallya commented 2 years ago

@pjschrock Even I was also spent hours, and fortunately, I have an old account UA-xxxx with views which works fine for me. Need to see when either this plugin gets updated or achieved with a notice.

patrickchoi commented 2 years ago

You can still create a UA tracking ID in Google Analytics https://support.google.com/analytics/answer/10269537?hl=en

amusameh commented 2 years ago

Hi guys,

Any updates on this issue? Would be great to share any solutions if there are any.

Thank you in advance.

acedigibits commented 2 years ago

New Warning from Google : "Universal Analytics properties will stop collecting data starting July 1, 2023. It’s recommended that you create a Google Analytics 4 property instead. " .

Please let us know if there is any update on this issue ?

victorsosa commented 2 years ago

Sorry, I am back

I was looking into the issue and found this: About the property: "If your Universal Analytics property name is "Example property (UA-nnnnnnn)", your GA4 property name will be "Example property (xxxxxxx)", without a "UA-" prefix, and where xxxxxxx is a new property number"

Check if your Google Analytics property is impacted

If you created your property before October 14, 2020, you're likely using a Universal Analytics property.
If you created your property after October 14, 2020, you're likely using a Google Analytics 4 property already, and no action is required.

Also "Google Analytics 4 is our next-generation measurement solution, and it's replacing Universal Analytics. On July 1, 2023, standard Universal Analytics properties will stop processing new hits. If you still rely on Universal Analytics, we recommend that you prepare to use Google Analytics 4 going forward."

For more info: https://support.google.com/analytics/answer/11583528

About continue this project, it will not because the new GA4 is base on the firebase platform and there is already a pluging for firebase components.

Moghul commented 2 years ago

@danwilson Anything on this?

victorsosa commented 2 years ago

:You can migrate to GA4 property in google: "If you still rely on Universal Analytics, we recommend that you prepare to use Google Analytics 4 going forward."

Moghul commented 2 years ago

Does the plugin stay the same, and you just change the property? Is that what you are saying @victorsosa ?

victorsosa commented 2 years ago

yes, that's the point. They just changed the ID format of the GA property

acedigibits commented 2 years ago

window.ga.startTrackerWithId("UNIVERSAL_ID") works , but window.ga.startTrackerWithId("GA4_ID") does not work (no data showing in realtime .)

@victorsosa can you guide if there is any change needed in above code ?

tajinder-logiciel commented 2 years ago

@acedigibits this library is not supported GA4.

tajinder-logiciel commented 2 years ago

Is there any library that supports Google analytics 4 (GA4) for ionic apps? With CDN web implementation on the app, it is working on android devices but on ios devices it is not working

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXXXXX');
</script>
aerialglasgow commented 1 year ago

Very informative! This is such a useful plugin by Dan Wilson. I did notice you can still set up both a Universal ID and new G4 tracking ID (at same time) using advanced options when setting up a new property in analytics. So you should be able to use the Universal ID in this plugin till next July 2023, then hopefully fall back to the G4 tag in a new way which may develop.

aerialglasgow commented 1 year ago

Yep this is working, just set this up in a Cordova app using this plugin. Real-time tracking is picking up Universal ID.

victorsosa commented 1 year ago

@aerialglasgow can you show you setting and code so other could do the same?

acedigibits commented 1 year ago

Universal ID was working and will continue to work. Point is that GA4 IDs are not working, which is mandatory after July 2023. So if this plugin cannot work on GA4 is there an alternative ?

aerialglasgow commented 1 year ago

Hi @victorsosa @acedigibits, I didn't change my use of the plugin (which does still work) I only wanted to point out that after checking this out the Universal ID is still available, but under Advanced Options when creating the property in Analytics. I don't know of an alternative for GA4 unfortunately. I'm not sure if this plugin can be modified to accept GA4 ID's, possibly, I haven't looked at the code.

henkkelder commented 1 year ago

There is another problem with this plugin. Starting august 2022 new Android apps must use target SDK Version 31. Existing Android Apps must be at SDK 31 in November 2022. This plugin doesn't work properly at SDK 31 :-(.

image

BenLaKnet commented 1 year ago

Is there a solution to use GA4 with this plugin ? IS there another possible plugin ?

EYALIN commented 1 year ago

There is another problem with this plugin. Starting august 2022 new Android apps must use target SDK Version 31. Existing Android Apps must be at SDK 31 in November 2022. This plugin doesn't work properly at SDK 31 :-(.

image

fixed in recent version

victorsosa commented 1 year ago

There is another problem with this plugin. Starting august 2022 new Android apps must use target SDK Version 31. Existing Android Apps must be at SDK 31 in November 2022. This plugin doesn't work properly at SDK 31 :-(. image

fixed in recent version

Your fix was merge and will be in the 1.9.2 package release

victorsosa commented 1 year ago

npm notice Publishing to https://registry.npmjs.org/

lopezasin commented 1 year ago

Please @danwilson. Community need you. Is possible update the plugin for GA4? Thank you very much!

purinder-chawla-aristocrat commented 1 year ago

Please @danwilson. Community need you. Is possible update the plugin for GA4? Thank you very much!

erikyuzwa commented 1 year ago

It looks like GA4 support is being tracked in #613