-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Google tag manager not working on IOS #1433
Comments
Can you provide a sample project I can use? |
Seems very unlikely that this is a Capacitor issue. Will re-open if we get more info |
I've encountered the same issue. In an app we've made statistics are registered from Android users, but not from iOS users. If I debug the iOS version locally trough the Safari inspector, it is not sending out any requests to Google. Could it be that the WKWebView is not allowing this? There is no log or warning why this is (not) happening... To see for yourself you can create an empty capacitor project an add the following HTML and run it on a iOS device.
I'm willing to help, but right now I don't have any staring point... |
Update: I've found out there are two reasons why it fails:
|
@naranjamecanica Does 2) refer to something like this? |
Experiencing the same: no API output traffic to google at all. Basic Google Analytics implementation with their standard integration script as seen above in @naranjamecanica's example.
|
Same issue. Any fix? Thx |
Ok i've fixed
|
@Snake231088 is it possible to implement a similar fix for a GTM script? |
|
I've managed to relay the
function() {
return function() {}
}
function() {
if (window.Storage) {
return window.localStorage.getItem('_clientId') || undefined;
}
return;
}
function() {
return function() {
if (window.Storage) {
window.localStorage.setItem('_clientId', ga.getAll()[0].get('clientId'));
}
}
}
Essentially, |
@tyeon95 thanks, it works. |
4.i is only necessary if you're using ionic capacitor for android and ios builds as it the uri of the app in these cases starts with the capacitor protocol capacitor://, and not required if it's only for webapp build |
This really work for me. |
Anyone get this to work for gtag? I can't mimic what's being discussed. Here is my code: const GA_LOCAL_STORAGE_KEY = 'ga:clientId'; gtag('config', 'ga-key', { gtag('set', { |
+1 |
Do you mind sharing with me? None of the solutions on this page have worked for me. |
@smoosh911 sorry , I meant : I don't find the solution |
@smoosh911 |
@nseb i found a solution a while ago. I use GTM with firebase now. It was annoying to have to rewrite but it works pretty well. |
@smoosh911 , can you detail me your solution ? |
@nseb There is a capacitor community plugin for Firebase. There is also a library for GTM called react-gtm-module. Create accounts for firebase and gtm, initialize both in their respective libraries in the app, and then they will work together. Note that GTM will only work within web. Firebase will work on both web and mobile. GTM not working on mobile is due to GA4 not having an easy solution to turning off cookies and disabling the protocol method. |
You dont need Firebase for Google Tag Manager to receive events. Credit to @ericgopak for showing this. |
@stanriley If you were responding to what I said, you are absolutely right that Firebase is not required for GTM to fire events. I am using Firebase with GTM is all, not that GTM is technically linked or reliant on Firebase to initialize. About your post, I cannot get your solution to work. You've specified that you have your solution working for Android and Web, does it work for iOS? |
I have the same issue and this does not work on iOS for me. Have you made it work on iOS? |
Yes. Please do the steps that tyeon95 commented on Jun 15, 2020 for creating GTM variables. Then do the gtag('set', {'checkProtocolTask': function() {/nothing/}}); after the TagManager script. It works - here's proof - Analytics for PWA, iOS, and Android. |
Hello. I just commented and yes does work without Firebase. Hope this helps.
Thanks
Stan
…Sent from my iPhone
On Apr 3, 2021, at 7:57 AM, Andreas Aeschlimann ***@***.***> wrote:
You dont need Firebase for Google Tag Manager to receive events.
Building an Ionic Angular iOS App - Everything works on Web and Android.
This worked for me! Placed right after the TagManager script
gtag('set', {'checkProtocolTask': function(){ /* nothing */ } });
Credit to @ericgopak for showing this.
Not using Firebase.
I have the same issue and this does not work on iOS for me. Have you made it work on iOS?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Nice. Some confusion here, because for me, Google Analytics looks different – I see different menus on the left. I wouldn't know where to set built-in variables because I am not using GTM. I created my new «Property» directly from Google Analytics. |
Ok. I am using google tag manager and it forwards the requests to google analytics.
Hope this helps.
Stan
…Sent from my iPhone
On Apr 3, 2021, at 9:14 AM, Andreas Aeschlimann ***@***.***> wrote:
Yes. Please do the steps that tyeon95 commented on Jun 15, 2020 for creating GTM variables. Then do the gtag('set', {'checkProtocolTask': function() {/nothing/}}); after the TagManager script.
It works - here's proof - Analytics for PWA, iOS, and Android.
Nice.
Some confusion here, because for me, Google Analytics looks different – I see different menus on the left.
I wouldn't know where to set built-in variables because I am not using GTM. I created my new «Property» directly from Google Analytics.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Thanks a lot for your helpful input. One problem people (like me) may have is that Google pushes you to use GA without GTM. When creating a new property for tracking on GA, you must check this hidden advanced option: Now I have followed your instructions and I made the analytics work in the browser and Android again, but it still fails on iOS. I will post screenshots that other users may find helpful as well: The code in your Ionic application: Added the following on index.html. Added the following to AppComponent. (In my case, navigationService.router is a reference to the Angular router.) Setup on Google Tag Manager website: The Google Tag. The configuration of the tag. The fields to set as described by @tyeon95. I don't see why it is still not working yet on iOS, but we are probably close. Any help is very welcome! @stanriley is this the way you have setup your GA/GTag account? EDIT: Having that said, the version of @Snake231088 works well on iOS. But Google says GA is the legacy way, so it would be nice to make it work with GTag. |
You must disable checkProtocolTask but You can only do this in GA3
(universal analytics). You cannot do this in GA4 (firebase and the new
analytics which are event based). There is an outstanding ticket for ga4 to
implement checkProtocolTask but it isn’t being worked on yet.
On Sat, Apr 3, 2021 at 10:31 AM Andreas Aeschlimann < ***@***.***> wrote:
Thanks a lot for your helpful input. One problem people (like me) may have
is that Google pushes you to use GA without GTM. When creating a new
property for tracking on GA, you must check this hidden advanced option:
[image: Screenshot 2021-04-03 at 18 24 53]
<https://user-images.githubusercontent.com/2174826/113484693-f2debe80-94a9-11eb-990e-621d1241955b.png>
Now I have followed your instructions and I made the analytics work in the
browser and Android again, but it still fails on iOS. I will post
screenshots that other users may find helpful as well:
*The code in your Ionic application:*
Added the following on index.html.
[image: Screenshot 2021-04-03 at 18 19 32]
<https://user-images.githubusercontent.com/2174826/113484720-16096e00-94aa-11eb-96ee-89d36e57a33b.png>
Added the following to AppComponent. (In my case, navigationService.router
is a reference to the Angular router.)
[image: Screenshot 2021-04-03 at 18 19 43]
<https://user-images.githubusercontent.com/2174826/113484727-26214d80-94aa-11eb-82ee-2c568cb10d94.png>
*Setup on Google Tag Manager website:*
The Google Tag.
[image: Screenshot 2021-04-03 at 18 20 05]
<https://user-images.githubusercontent.com/2174826/113484738-36392d00-94aa-11eb-8df3-4d08d9d21d72.png>
The configuration of the tag.
[image: Screenshot 2021-04-03 at 18 20 17]
<https://user-images.githubusercontent.com/2174826/113484746-3afde100-94aa-11eb-9124-1e9bb33dbffa.png>
The fields to set as described by @tyeon95 <https://github.com/tyeon95>.
[image: Screenshot 2021-04-03 at 18 20 47]
<https://user-images.githubusercontent.com/2174826/113484751-43561c00-94aa-11eb-84f8-e40fb7c03af4.png>
I don't see why it is still not working yet on iOS, but we are probably
close. Any help is very welcome! @stanriley <https://github.com/stanriley>
is this the way you have setup your GA/GTag account?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1433 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADZZCYGLGTDPJRIZPLPYX3LTG47EZANCNFSM4HIO3EXA>
.
--
Thanks,
Michael Perry
<http://www.linkedin.com/in/perrymichaelscott>
<https://www.facebook.com/michael.perry.98892>
<http://google.com/+MichaelPerry911>
<https://www.youtube.com/channel/UCyyJGu8O34qMMXjPKuPoxDQ?>
<https://github.com/smoosh911>
<http://stackoverflow.com/users/3695931/smoosh911>
|
Yeah, it looks that way. It's a shame we have to use the "legacy" product for now. In my opinion Google made a mess by mixing up products. I was using GA for over 10 years and I had no idea about all these new products (GT, GTM, etc.) and about the connection with GA. I hope that we can do it the new way at some point, though. Thanks for all the constructive posts in this issue! |
@andreas-aeschlimann have you managed to get gtm version to work? Also solution by @Snake231088 is not working for me on ios, can you give me example of your code where it works? |
As I said, I had to downgrade to normal GA. No GT involved, just the old Analytics script. For now I am quite happy as it is working. |
This is my code(added in index.html):
I have replaced UA-XXXXXX-X with universal property created in analytics console, but I still see no data received when I run the app from iOS. |
@vaskea you should remove the last line (pageview) and listen to changes on navigation. There are a lot of examples around how to do it. In Angular, you can subscribe to |
@andreas-aeschlimann Great thanks, that worked! |
@smoosh911 Were you able to get GA4 to work on iOS with Firebase? I have been dissecting & replicating your comments in this thread to no avail. I am using this Firebase plugin, it seems to initialize on iOS according to the debug logs but it never sends any data. Any ideas? Thanks in advance! |
Hi there everyone. In the current project, we need to both support Universal Analytics and Analytics v4 (because as far as I get V4 still does not have all the features of the old UA). I've managed to add support to GA V4 with Firebase Analytics (with this plugin https://github.com/capacitor-community/firebase-analytics). And now I need to support also Universal Analytics but to be honest, I'm totally lost. Do I need to use Google global site tags? Do I need to use Google Tag Manager? Are there any capacitor plugin to do that or do I need to find just a react-plugin? For the GTM I saw this from the Google Documentation I saw this page https://developers.google.com/tag-platform/tag-manager/ios/v5 and my confusion is just growing :D What do you actually use at the moment? |
Thanks for all the comments on this thread. I battled this for two days before finding this. My app uses AngularFire (along with Ionic) which I thought was the cause of the issue. For anyone else using AngularFire + Ionic and not seeing Firebase Analytic events from iOS (but Auth, Firestore & Functions work on iOS and everything works on desktop and Android), try adding the Capacitor Firebase plugin @tramert mentioned above (https://github.com/capacitor-community/firebase-analytics). Adding that solved the problem for me, no additional configuration required. Thanks again to all who contributed in this thread. |
@BL-marcusrogers are you still using Angular/fire analytics to track or do you use the native plugin instead? |
@dodomui I am still using AngularFire analytics, not the native plugin. I have not made any changes to server.iosScheme. My stack is Angular/fire 6 + Firebase 8 + Capacitor 3 (I use ngxs-labs/firestore-plugin which is not yet compatible with Angular/fire 7, so my stack is a version old for now). |
@BL-marcusrogers Got it, thanks. I found the issue is because @angular/fire 7 |
Did you solve the issue? |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
The configuration for the tag manager was done by adding something like the following to the index.html of the project:
Debugging the issue the apparently reason that it isn't working is because when an event is triggered, the app makes a GET request to
https://www.google-analytics.com/collect
, but on the iOS build inspected through the Safari develop console, that request is never made.Also, when opening the page from the Safari browser it's working as expected.
The versions are:
"@capacitor/core" : "^1.0.0-beta.17"
"@capacitor/ios": "^1.0.0-beta.19"
"@capacitor/cli": "^1.0.0-beta.19"
Testing from an iPhone 6 running IOS 11.4.1
The text was updated successfully, but these errors were encountered: