I have a problem with sending user id through GTM. I'm trying to configure it with Analytics - Web + App on web.
I have added a dataLayer variable, with following properties:
Name (for use in GTM): User ID
Variable name: user_id
Version: 2
Then, in my app I'm executing:
window.dataLayer.push({ "user_id" : "some_user_id" });
But this variable never gets sent via collect request for GTM. Could anyone tell me where the problem can be?
I also tried
window.dataLayer.push({ "User ID" : "some_user_id" });
but that didn't work too.
If you send it after GTM snippet (so after gtm.js native trigger) you have to add an event in dataLayer and use it to trigger the hit with userId field.
Related
I've got facebook, google and regular registration/login turned on on my website. The problem I have is that the email address is stored in different fields depending on how the user first joined.
For regular users, it is in field emails[0].address. For facebook and google authenticated users it is in field services[0].email.
At various places in the client (templates, events) and on the server (method), I just want to call one method that works out which field to use and returns the email address. I also want to do something similar for the verification field.
I'm fairly new to meteor and the only ways I've found to do the above so far is to repeat the same logic in the client and on the server which doesn't sit well with me.
The best thing to do would be to transfer the email address to 'emails' if they log in with facebook, google or another services for the first time. This would also make it more future proof incase you add other services, since meteor will always use emails.address (including in other packages)
Server side code:
Accounts.onCreateUser(function(user) {
user.emails = user.emails || []; //If its null set it to an empty array
if(user.services.facebook) {
user.emails.push({address: user.services.facebook.email, verified: false});
}else if(user.services.google) {
user.emails.push({address: user.services.google.email, verified: false});
}
return user;
});
Then you can just check Meteor.user().emails[0].address every time.
Note: If not published due to the autopublish package you may have to publish the emails field for it to work on the client.
You may also have to run this the first time for users who have already logged in before:
Meteor.startup(function() {
Meteor.users({'emails':{$exists: false}}).fetch().forEach(function(user) {
var email = (user.services.facebook || user.services.google).email;
if(email) Meteor.users.update({_id: user._id},{$push:{emails:{address: email, verified: false}}});
});
});
I'm not sure if facebook and google both use email in the services key, if they do the above should work fine. If they don't you can edit out the key that is used for google or facebook, in case one is emailAddress instead of email for example.
I am building a Windows Phone 8.1 application and want to add push notifications from Windows Azure. I am creating the channel by using CreatePushNotificationChannelForApplicationAsync, after which I take the resulting URI and store it in the Azure database. When trying to send a push notification by using push.wns.sendToastText01, I get the following error in the Azure logs:
Error in script '/table/Message.insert.js'. Error: 400 - An invalid tag 'https://db3.notify.windows.com/?token=AwYAAAC3tTi3W5ItZ0hWdZ3FLmELt%2flHcwpsM...' was supplied. Valid tag characters are alphanumeric, _, #, -, ., : and #.
I noticed that the channel URI contains the '%' which does not appear among the valid characters, yet that is the URI that gets generated in the client application. Am I using a wrong method for sending push notifications or is there something else I am missing?
Edit: I am using Node.js for backend in Azure.
request.execute({
success: function() {
push.wns.sendToastText01(channelUri, {
text1: "Google Plus Friend Tracker",
text2: item.content,
param: '/ChatPage.xaml?friendGoogleId=' + item.author_id
})
}
});
Looking at the wns object documentation, the first parameter would be the tags that you are sending to. Since you're providing a channel in the code above, you are getting the error specified.
The backend does not need to provide the channel URI, as this was associated with the Notification Hub via the client-side registration action. If you are broadcasting the message, you would just provide null as the tag value. Otherwise, you can use the tags that were specified when you registered the channel URI.
For more about the process, see the "Get started with push" tutorial. There is also an example of using a tag (user ID) in the "Send push notifications to authenticated users" tutorial. For more on tags in general, the Notification Hubs breaking news tutorial is also good.
I need to display 'Pure HTML Dashboards' or 'Custom Components' as depicted in the following link https://ga-dev-tools.appspot.com/demos/embed-api/
I have google analytics account & it shows me the real time statistics perfectly for my website, but i need to display the same using the api as shown in the following link:
https://github.com/googleanalytics/embed-api-demos/blob/master/site/3-custom-components.html
I have replaced my client id in the following code:
gapi.analytics.auth.authorize({
container: 'auth',
clientid: '623325626209-j1jm9d78ge0v4uf8b9cor31qsirungrq.apps.googleusercontent.com',
});
I also updated the end date to current date as follows:
query: {
'metrics': 'ga:sessions',
'dimensions': 'ga:date',
'start-date': '30daysAgo',
'end-date': '2014-09-05'
},
So when i run the code it shows a button "Access Google Analytics", when i click on it i get the following error:
That’s an error.
Error: origin_mismatch
Application: Project Default Service Account
You can email the developer of this application at: fz1990#gmail.com
Request Details
=
scope=https://www.googleapis.com/auth/analytics.readonly https://www.googleapis.com/auth/userinfo.email
response_type=code token id_token gsession
redirect_uri=postmessage
cookie_policy=single_host_origin
proxy=oauth2relay591552393
state=524099008|0.3938720987
origin=http://localhost:27363
include_granted_scopes=true
client_id=656169223314-dbc8l4c7ro20hn8vcqqtd9rhd0e6arcb.apps.googleuserconte
Can somebody plss help me to fix this issue?
Thanx in advance
Origin mismatch is normally caused by the Javascript origins not being set correctly in the API project console. You need to make sure that the Javascript origins match the domain from which your requests are coming and to which you are returning the user after sign in.
In your case you are still using the client_id from the tutorial you need to create your own. More details can be found in the developer documentation for the embeded API in the "Create a client ID and client secret" section.
Basilcy you need to go to Google Developer console and register your application. The link above to the documentation will walk you though creating that. Hint: don't for get to add a product name and email address.
At this time the Real-time API is still in beta you will need to apply for access to it. Real time reporting api private beta fill out that form you wont hear anything from Google just wait 24 hours and give it a try it normally works by then.
I have a single page app that uses Google Analytics. The account key and domain change per-environment because the tracking is meant to be segmented by environment so the setup is somewhat involved.
I would like to be able to verify that the _gaq object has my account key as expected and that is has the domain name set as expected. When I run the code google provides to get the account key, I only get back A-XXXXX-X.
_gaq.push(function() {
var pageTracker = _gat._getTrackerByName();
console.log(pageTracker._getAccount()) // Logs UA-XXXXX-X, not my actual number
});
What is the right way to verify the correct configuration of the _gaq object?
You can verify correct configuration by running these commands in console:
ga(function(tracker) {
console.log( tracker.get('trackingId') )
console.log( tracker.get('cookieDomain') )
});
This will log out the tracking ID and domain google is expecting you to track against. If the configuration is set up correctly, these values will be what you have configured.
I'm using the following code
_gaq.push(['_setCustomVar',1,'logged-in','administrator',1],['_trackPageview']);
to track logged-in user levels on my site (running WordPress).
Now my problem is that in the last month I had around 100 new registrations, but Google Analytics only shows me 65 registered users active on my site.
Is this an error in interpreting the results or am I doing something wrong?
PREAMBLE
With Google Analytics(GA), it's impossible to get ALL your hits registred. This is not a GA specific problem. Any analytics tool can be affected.
Imagine for instance, that the user gets its connection broken while registring on your WP site. Chances are that the javascript code won't be executed. The new user will be registred hopefully, but GA won't be notified.
WORKAROUND
This workaround would be to tied the notification of GA with your registration process right on the server side:
Step 1: Register a php function with the user_register hook.
add_action('user_register', 'myplugin_registration_save');
function myplugin_registration_save($user_id) {
// GA will be notified here ...
}
Step 2: Inside this registred function notify GA of the new user registration.
Here comes php-ga. It's a GA client written in PHP. You can implement nearly every parameter and tracking feature of the original GA Javascript client. Call it to track your GA custom vars.
Here is a sample code from the php-ga site:
use UnitedPrototype\GoogleAnalytics;
// Initilize GA Tracker
$tracker = new GoogleAnalytics\Tracker('UA-12345678-9', 'example.com');
// Assemble Visitor information
// (could also get unserialized from database)
$visitor = new GoogleAnalytics\Visitor();
$visitor->setIpAddress($_SERVER['REMOTE_ADDR']);
$visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
$visitor->setScreenResolution('1024x768');
// Assemble Session information
// (could also get unserialized from PHP session)
$session = new GoogleAnalytics\Session();
// Assemble Page information
$page = new GoogleAnalytics\Page('/page.html');
$page->setTitle('My Page');
// Track page view
$tracker->trackPageview($page, $session, $visitor);
THERE IS MORE
Even if you implement the workaround, it may not be able to notify GA sucessfully. If GA server experiment some heavy load for instance, your notification may be lost.
I would advice you to use both system notification : GA Javascript client AND GA PHP client.
Assign them two distinct events 'JS-new-user-registred' and 'PHP-new-user-registred'. With two registred events you improve the quality of your analytic data. You improve the new registrations notification rate too.
Always keep in mind that this approach may not be 100% accurate. For example, on the client side the ga.js file may be blocked (firewall etc). At the same time, your PHP client may not be able to notify succesfully GA. It results that the new registration is not tracked.