kraihn / cordova-plugin-tag-manager Goto Github PK
View Code? Open in Web Editor NEWGoogle Tag Manager plugin for Cordova
License: MIT License
Google Tag Manager plugin for Cordova
License: MIT License
Hi @kraihn ,
The error calback of the dispatch function triggers and it's returning an "Invalid action" msg.
Any suggestion what does it mean? or why I'm getting this error?
Is there any other plugin that may be needed like com.google.playsevices or anything to solve this?
I have this error in my log (both in simulator and on a real ios device):
VERBOSE: GoogleAnalytics 3.13 -[GAIRequestBuilder requestGetUrl:payload:] (GAIRequestBuilder.m:195): building URLRequest for https://ssl.google-analytics.com/collect VERBOSE: GoogleAnalytics 3.13 -[GAIBatchingDispatcher dispatchWithCompletionHandler:] (GAIBatchingDispatcher.m:632): Sending hit(s) GET: https://ssl.google-analytics.com/collect?... INFO: GoogleAnalytics 3.13 -[GAIBatchingDispatcher didSendHits:response:data:error:] (GAIBatchingDispatcher.m:226): Hit(s) dispatched: HTTP status -1 INFO: GoogleAnalytics 3.13 -[GAIBatchingDispatcher deleteHits:] (GAIBatchingDispatcher.m:529): hit(s) Successfully deleted INFO: GoogleAnalytics 3.13 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:237): 1 hit(s) sent
Reported without any answer here:
http://stackoverflow.com/questions/30363622/google-analytics-http-status-1-when-sending-hits-by-request-get-https-ssl-g
Any idea?
Hi,
How to debug track events? I was using Charles and inspect devices of chrome.
But, it isn't sending any request to google analytics.
This is my code:
var initWebView = function(containerId) {
analytics = $window.plugins && $window.plugins.TagManager;
if (analytics) {
analytics.init(
function callSuccess() {
console.log('SUCCESS');
},
function callError(error) {
console.error('ERROR', error)
}
, containerId, 30);
}
};
...
var pushWebView = function(data) {
data.domain = $scope.getCurrentDomain();
if (analytics) {
analytics.trackEvent(
function callSuccess() {
console.log('SUCCESS AGAIN');
},
function callError(error) {
console.error('ERROR AGAIN', error);
},
data.event, data.event, 'data', data);
}
};
Thanks
cp: copyFileSync: could not write to dest file (code=ENOENT):/Users/mac/developer/mandi-app/platforms/android/res/xml/config.xml
I find the above mentioned error while running "ionic cordova build android" command after installing plugin.
cli packages: (/Users/mac/developer/mandi-app/node_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
Cordova Platforms : android 7.1.1 ios 4.5.4
Ionic Framework : ionic1 1.3.2
System:
Node : v8.11.3
npm : 5.6.0
OS : macOS Sierra
Xcode : Xcode 9.0.1 Build version 9A1004
Environment Variables:
ANDROID_HOME : /Users/mac/Library/Android
Misc:
backend : pro
new TagManager(); doesn't work, what do i do wrong?
Hi,
There is a example about how use this plugin?
Thanks,
Γrica
Hi kraihn,
I've tried to use your plugin to send the statistics to google analytics using GTM, but it doesn't seem to work. I can't see any statistic in Google Analytics.
I have created all the variables/triggers/tags that you described in the wiki page.
I am using cordova -version=4.2.0.
Could be the error the cordova version?
Does your plugin work with GTM v2?
Is there any workaround I could do?
Thanks in advance.
Best Regards,
Emanuel
I'm trying to install the plugin. But i'm getting an 404 error and not able to install.
Error: Registry returned 404 for GET on https://registry.npmjs.org/com.jareddickson.cordova.tag-manager
Can anyone please help?
Fetching plugin "com.jareddickson.cordova.tag-manager" via npm
Error: Cannot find plugin.xml for plugin "package". Please try adding it again.
I experienced this problem before with Facebook and Google analytics plugins - the following solution fixed it for me:
http://www.thedevline.com/2014/06/unexpected-top-level-exception.html
I now need to install Google Tag manager in addition to these other plugins. Installing the plugin as it says in the read me triggers the following error when building on Android at 94% (it works fine on iOS):
:preDexDebug UP-TO-DATE
:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/analytics/internal/Command$1;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
:dexDebug FAILED
FAILURE: Build failed with an exception.
Additional info:
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/analytics/internal/Command$1;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 10.506 secs
Is it possible to run Google analytics with Tag manager? If so any idea how to get around this error?
Cheers, Stu
I'm trying Ionic2 and it would be nice if we there was a way to access the plugin directly in js if it exists.
The instructions say:
When being used in combination with AngularJS, it is recommended to use Angulartics with the Cordova GTM plugin (angulartics-gtm-cordova).
I'm searching around and can't seem to find anything on this Cordova GTM plugin. Could somebody provide more info or is the documentation out of date? Thanks!
Hi,
Using the README.md command I'm getting this :
-> cordova plugin add com.jareddickson.cordova.tag-manager
Fetching plugin "com.jareddickson.cordova.tag-manager@~1.0.1" via npm
Error: Cannot find plugin.xml for plugin "package". Please try adding it again.
System:
Debian
node -v β v6.8.0
npm -v β 3.10.8
cordova -v β 6.4.0
EDIT: cordova plugin add cordova-plugin-tag-manager
Works ;)
Right now (from readme) it looks like it is allows only logging pages/events with GTM only.
Thanks a million for writing the plugin!
One suggestion...
It took me a long time to realize why i was not getting the GTM plugin to work. It would be helpful that you say somewhere in the setup documenting that the config.xml has to have this whitelist statement
<!-- Don't block any requests -->
<access origin="*" />
otherwise the GTM plugin is blocked from sending data out.
All Cordova doc strongly recommends NOT using that line so i had removed it not knowing it was a prerequisite for the GTM plugin!
Bob Achgill
Hai @kraihn
Thanks for this plugin. great work
is it support only google Universal Analytics.
Is possible to use other tag type
Could you please add the wiki?
Please advice
Hi
I followed all the instructions on how to implement the plugin but I always get this error:
[INFO:CONSOLE(59)] "Uncaught module com.jareddickson.cordova.tag-manager.TagManager not found", source: file:///android_asset/www/cordova.js (59)
Do you have any idea what could go wrong?
Hello: Thanks for making this for us.
But when I used this plugin, and did tagManager.dispatch();
I can get the callback of success;
But my GA can't get anything because there's no post to GTM server from my app.
By the way, we've changed the native libraries of GTM to the newest libraries, both of two platform.
Thanks a lot!
Hi @kraihn , I manage to get everything working since last time, I'm getting hits on GA smoothly. The only thing I haven't been able to do is to get GTM to pass the different event information to GA.
I believe that I need to create a Data Layer variable to configure the event tracking params (fields: category, action, label and value) since if I set those values with a fixed string that's the value it sends to GA, and I need those to be what I'm sending from my app with "trackEvent" function.
So, I tried to create Data Layer variables with the data layer variable name as the params of your function are called, but it doesn't work, could it be that they are named different when being sent to GTM? or am I missing something else here?
I know this may not be an issue with your plugin but it's the only source I've got left to check on.
Thanks,
Jonatan
I had this two errors when I build:
error: no visible @interface for 'CDVPluginResult' declares the selector 'toSuccessCallbackString:'
[self writeJavascript:[commandResult toSuccessCallbackString:callbackID]];
error: no visible @interface for 'CDVPluginResult' declares the selector 'toErrorCallbackString:'
[self writeJavascript:[commandResult toErrorCallbackString:callbackID]];
Hi,
I have installed the plugin as suggested here https://github.com/kraihn/cordova-plugin-tag-manager
Below is my code
config.xml
<plugin name="com.jareddickson.cordova.tag-manager" spec="https://github.com/kraihn/cordova-plugin-tag-manager" />
Code to initiate GTM
`onDeviceReady: function() {
var tagManager = cordova.require('com.jareddickson.cordova.tag-manager.TagManager');
var trackingId = 'GTM-XXXXXX(application GTM Id)';
var intervalPeriod = 30;
var successGtm = function() {
alert("5");
};
var errorGtm = function() {
alert("6");
};
var errorDisGtm = function() {
alert("7");
};
// Initialize Tag Manager
tagManager.init(successGtm, errorGtm, trackingId, intervalPeriod);
tagManager.trackEvent(successGtm, errorGtm, 'Init', 'Any-Event', 'Any-Event', 1);
tagManager.dispatch(successGtm,errorDisGtm);
if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) {
hzm.shared.onDeviceReady(hzm.hubView.afterContentLoad);
} else {
hzm.shared.onDeviceReady();
setTimeout(hzm.hubView.afterContentLoad, 0); //this is the browser
}
hzm.events.onDeviceReady();
setInterval(hzm.shared.keepAlive, hzm.constants.TIME.KEEP_ALIVE);
hzm.vc.resetValues();
}`
When I run the application in xCode getting the following error:
I have also noticed that xCode Plugins folder doesn't have the CDVTagManager.m file inside it.
Please suggest and advise, it's a bit urgent. Thanks in advance.
Getting the following error after adding the CDVTagManager.m file manually
Hi,
i am trying to use two plugins in the same app:
(to collect the IDFA)
cordova plugin add https://github.com/appfeel/analytics-google-adid.git
(to use GTM)
cordova plugin add https://github.com/kraihn/cordova-plugin-tag-manager.git
but when i try to build i get:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/analytics/internal/Command$1;
After looking into this a little bit i think that this plugin includes libraries that should be dependencies? I think it might be something to do with libGoogleAnalyticsServices.jar??
Sorry if i have got this wrong but i can't get the two plugins to work well together,
Any ideas?
MB
So, in the Triggers section we're supposed to set the Fire On to {{event}} equals interaction and to {{event}} equals content-view for the two triggers, but in the left dropdown there is no {{event}}, just an "Event" and then if I use that ( Event ) and set to be equals to "content-view" would that be ok? Shouldn't we have a variable in the right hand side? I may say something stupid, I don't have yet a good grasp on the GTM mechanisms.
Hi Everyone,
Do you know how to configure the UserId using this plugin?
I am new to GTM, and I don't know if I'll be able to achieve this using this plugin.
https://support.google.com/analytics/answer/3123666?hl=en
Best Regards,
Emanuel
@kraihn @zwacky @wrousseau @DeonKuhn
How to configure the event tracking for specific "ID / classes" in GTM admin console.
Need to update any thing in code?
Please advice
This referenced hook is set to afterPrepare and is overwriting other custom plist / manifest configs.
Example:
Using custom-config to hide ios status bar, this will be overwritten by the tag-manager
<config-file parent="UIStatusBarHidden" platform="ios" target="*-Info.plist">
<true />
</config-file>
I have created the "Custom dimensions" under Admin in google analystics
For Example "PageName"
In GTM
Varaibles :
PageName - Data Layer Variable
Tigger :
Trigger Type: custom
event : All event
Tags
Tag Name: Events
Tag Type: Universal Analytics
Tracking ID: YourGoogleAnalyticsID
Track Type: Event
Category: DimensionCategory
Action: DimensionAction
Label: DimensionLabel
Custom Dimension
index : 1
value : {{PageName}}
In Mobile app
tagManager.pushEvent(function(){}, function(){}, {'PageName': 'HomePage'});
success function called but i didn't see any data....
Please advice.....
Trying to install/download your plugin via cordova cli but got this error.
Did download the git as a .zip in the meantime.
Fetching plugin "com.jareddickson.cordova.tag-manager" via npm
Fetching plugin "com.jareddickson.cordova.tag-manager" via cordova plugins registry
Failed to fetch plugin com.jareddickson.cordova.tag-manager via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: connect ETIMEDOUT 50.17.177.14:80
Hi there,
Thanks for the plugin, I'm however having troubles getting data to GTM. init
works fine, so does trackPage
. However, dispatch
does not seem to do much as I'm not getting any data on GA and when debugging the application, I see no network call to GA or GTM.
I know that my setup is correct as I have it working with the web version of the application which does not require cordova, and GA is receiving data fine with it.
If you have any idea of what could be going wrong, I'd really appreciate it,
Cheers
Hope, the current version of this plugin supports latest version of GTM!
I've a hybrid mobile app and I've created two separate GTM containers for iOS and Android.
Let me know - firstly, is this the right step to start with to go further with setting up using this plugin? or Should i use the same container ID for both iOS and Android that I have used for Web? Please clarify this point.
Since the Wiki is blank, I am not able to follow any instructions to set up GTM for my mobile app.
It would be really helpful, if someone can compile the process of setting up GTM using this plugin and how to track the data in GA. Sorry for some insane queries, but I am running short of time to set up GTM using this plugin. So, any quick reference or material would really help me a lot.
Thanks in advance.
For anyone having this error: Plugins/com.jareddickson.cordova.tag-manager/CDVTagManager.m:145:42: No visible @interface for 'CDVPluginResult' declares the selector 'toSuccessCallbackString:'
Must modify tagmanager plugin, class CDVTagManager.m
replace: [self writeJavascript:[commandResult toErrorCallbackString:callbackID]];
with: [self.commandDelegate sendPluginResult:commandResult callbackId:callbackID];
in methods: successWithMessage y failWithMessage
How I understood, I can only track GTM events. Is there a way to set GTM variables?
Thanks
I see here that support for IDFA was added.
I'm wondering how I can use those to make sure that we get demographics and everything in tags manager.
Also, if we want to map a user to a real userId in our database, is there a way to do this here? Would it conflict with the IDFA or advertiserID?
Is there any example on how to get this working?
thank you very much π π π
I need to use this approach: https://developers.google.com/tag-manager/devguide#datalayer. Is this possible with this plugin?
And somewhat related: Why can't we just use the regular implementation of GTM? Why would we need this plugin at all?
I am wondering if there is another way to allow GTM to do its work using the cordova-plugin-tag-manager plugin without having to have this in my config.xml?? When I take it out GTM stops working...
<!-- Don't block any requests -->
<access origin="*" />
I tried just having this instead but it did not allow GTM to function.
<access origin="https://www.googletagmanager.com/*" />
<allow-intent href="https://www.googletagmanager.com/*" />
Isn't it a security risk to use???
<access origin="*" />
what is the different between trackEvent and pushEvent?
Please advice....
Hi @kraihn ,
Could you please update docs on set up and how to integrate this plugin into ionic 2 Project.
thanks.
I installed the plugin and it reports to be sending data to the tag manager. However there is no data displayed? How can the data sent to the tag manager be viewed ? Is there some kind of guide ?
Hi,
I have created a mobile app container in GTM and as per the instuction on https://github.com/kraihn/cordova-plugin-tag-manager/wiki/GTM-Setup i have created tags,triggers and variables..
Here are the screenshots of the same.
This is my code
var tagManager = cordova.require('com.jareddickson.cordova.tag-manager.TagManager');
tagManager.init(function (s) {console.log(s)}, function (e) {console.log(e)}, trackingId, intervalPeriod);
tagManager.trackPage(function (s) { console.log(s)}, function (e) {console.log(e)}, 'index.html');
tagManager.trackEvent(function(s){console.log(s)}, function(e){console.log(e)}, 'Link', 'Click', 'testClickEvent', 1);
tagManager.dispatch(function(s){console.log(s)}, function(e){console.log(e)});
I see the following log - when i debug my Android app on chrome.
initGTM - id = GTM-XXXXXX; interval = 1 seconds
trackPage - url = index.html
trackEvent - category = Link; action = Click; label = testClickEvent; value = 1
dispatch sent
I donβt see any Events on GA .
Please let me know if i have missed any configuration.
Also.. itβs been more than 24hrs i have created GTM account and GA account
Also please let me know if u need any information to help me debug the issue
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.