Mixpanel: distinct_id being set but events not recording against profile - mixpanel

I am setting the identity for a user when the user logs in
<script type="text/javascript">
mixpanel.identify("<?php echo $name; ?>");
mixpanel.track("Login");
</script>
When I look in the Live View, the event is being tracked and the correct distinct_id (i.e. the $name) is recorded against the event.
When I look at the profile that matches the $name there is nothing tracked.
Any ideas?

Mixpanel will link events and people based on the property called 'distinct_id'. Your call to identify in the javascript library is what is setting that property.
You should check to see if the profile you're looking at is related to the same distinct_id which will be shown in the url.

Related

How to include reCAPTCHA v3 in the background of pages?

In the reCAPTCHA v3 docs, it says
reCAPTCHA works best when it has the most context about interactions with your site, which comes from seeing both legitimate and abusive behavior. For this reason, we recommend including reCAPTCHA verification on forms or actions as well as in the background of pages for analytics.
How do we run it in the background of pages?
Let's say I have a React app that handles multiple web pages, and for one of my web pages, it is a sign up form where I want to get a risk score when users sign up. When the docs say to run reCAPTCHA in the background on other pages, does that mean it's running on other pages as long as <script src="https://www.google.com/recaptcha/api.js?render=_reCAPTCHA_site_key"></script> is in the header? Or do we need to call grecaptcha.execute(...) on all the other pages, and not just the signup page?
As long as you have the script attached, it will run in the background of pages. You can see that it's running if the reCAPTCHA banner/icon is showing on the page (usually bottom right corner). grecaptcha.execute(...) should be run on a specific action, like when you click a button to sign up for example.
#jojochuu, your answer is exactly right. Thanks for that.
I found another reason to run grecaptcha.execute. Logging. Loading api.js (the second line in the code below) is sufficient to activate recaptcha. It displays the flyout recptcha button.
I chose to add the second script that does call grecaptcha and gets the token. Then I use the token to get the score and any error codes from google. I log that data along with the visitor's IP address and a timestamp so I can see how the score changes over time. I can then compare my logs with access logs and maybe spot some IPs I want to ban. Mostly, I just want to know how score changes. I'll disable the logging by removing the second script block.
This is the best tutorial I found. Combining it with the google docs was enough to learn how to do recaptcha right.
<input type="hidden" id="visitor_ip" value="<?=$visitor_ip; ?>">
<script src="https://www.google.com/recaptcha/api.js?render=public-site-key" async defer></script>
<script>
// This correctly gets the token, but doesn't verify the user response (action).
function execGrecaptcha() {
grecaptcha.ready(function() {
grecaptcha.execute('<?=$settings->recap_public; ?>', {action: '<?=$actionName; ?>'}).then(function(token) {
logRecaptchaResults(token);
});
});
}
// Run after page loaded
window.onload=execGrecaptcha;
// Send token/ip to server for logging via ajax
function logRecaptchaResults(token) {
var vip=document.getElementById('visitor_ip');
$.ajax({
url: "https://<?=HOST_NAME_DOT; ?>domain.com/ajax/logit.php",
type: "get", //send it through get method
data: {
"token": token,
"visitor_ip": vip.value
},
});
}
</script>

Google Tag Manager - Create Event with Inline onclick attribute

I have a website where I am using Google Tag Manager to fire my Google Analytics tracking.
<!-- Google Tag Manager -->
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','********');
</script>
<!-- End Google Tag Manager -->
On the page, I wanted to track link clicks that open a modal window.
So, I put this code:
onclick="ga('send', 'event', 'Test', 'Take-Test', 'English');"
However, that is not working and it's not pushing the event into Analytics.
After doing a lot of digging, I thought maybe the issue is that GTM uses gtag.js instead of the older analytics.js library, so the structure of my onclick event had to be different.
My source for this was: https://developers.google.com/analytics/devguides/collection/gtagjs/migration#track_events
Based on this, I'm thinking my onclick event has to look like this:
onclick="gtag('event', 'Take-Test', {'event_category': 'test','event_label': 'English'});
However, I can't seem to confirm that with a GTM implementation it is using gtag.js, so I don't know if this is correct still.
All I know is that I really want to push this event into Analytics properly.
As a side note, I realize I can probably create GTM firing rules for this, however for reasons beyond my control, I have to create the onclick event in the HTML code and not via GTM.
Many thanks in advance for any insight!
Your ga('send' ...) call would not work in this case because
GTM automatically sets unique tracker names for its tags, which will not match the tracker name of your on-page analytics object.
(cf. https://www.lunametrics.com/blog/2015/01/21/gtm-existing-tracking/)
You would either have to find out the tracker name that GTM is using and modify your send call to something like this
ga('trackerName.send', 'event', ...)
or track the click using a GTM tag.
A bit old thread but anyway.
Had the same problem until I put this at the top of page:
<script>window.onload = function(){
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
ga('create', 'UA-XXXXXXXX-X');
.......
Especially the ga('create', 'UA-XXXXXXXX-X') seems to be crucial.
Maybe you should use analytics.js instead of ga.js:
https://developers.google.com/analytics/devguides/collection/analyticsjs/events
ga('create', 'UA-IDHERE-X', 'auto');
ga('send', {
hitType: 'event',
eventCategory: 'Your Category',
eventAction: 'Your Action',
eventLabel: 'Your Label'
});

Square payment form cannot execute requestCardNonce() to get nonce in Firefox 48.0.2

I've also submitted a request to Square support and hope to hear back soon.
Steps to reproduce
Load the Square payment form (copy-pasta from https://docs.connect.squareup.com/articles/adding-payment-form/#samplewebpage and add your Application ID and uncomment the lines to submit a request to the server) in Firefox 48.0.2 (latest release as of today). Here's a test URL: https://wideningwontwork.org/test.html
Leave all fields blank.
Click "Submit Query" button.
Expectation
All fields should be highlighted in red to indicate they are required.
Observation
Firefox cannot fire the event requestCardNonce() because it is not defined. Error message in Firefox console:
ReferenceError: event is not defined
requestCardNonce() payment:121
onclick() payment:1
Form is submitted to the server with nonce = "" (empty string or NULL).
Unfortunately, we've published a bug in the documentation We're working on it. Firefox requires an event to be passed as an argument to the function, whereas chrome and safari don't. If you edit the definition of requestCardNonce that you copied from the example to instead be the following, it should work for you:
function requestCardNonce(event) {
event.preventDefault();
paymentForm.requestCardNonce();
}
Notice the event argument. That's the part you have to add. Sorry for the confusion. We'll fix the docs.
edited to include a current screenshot as of 2016-08-31 17:04:43. This is the location in the script where you need to add an event argument to the function definition, and then where you need to provide the event argument to the function call on the submit button.
Having added event in both places, using firefox, I've gotten the following with your test form:

How to build html link to a google calendar event?

Using the google calendar API v3, I added an event to a google calendar. Now I want to built an html link so that someone can click and view the calendar event.
Here's what I have tried:
View Google
the href looks like:
https://www.google.com/calendar/feeds/default/private/full/bigstringhere1ovmuup7mjf0
Problem is I get a a 401 Error "Authorization Required"
How can I build a link to view/edit the calendar event based on a google calendar ID?
There is a way! To view a public calendar event, use a link of the form:
https://www.google.com/calendar/event?eid={event-id}&ctz={timezone}
where {event-id} is the unique event id, and {timezone} is one of these time zones.
Here's an example: link to a specific public calendar event.
If you have editing rights to the calendar this event is from, you will be able to edit the event and see the guest list. Otherwise, you just see the public information about the event.
Since it can be difficult to determine the event id, here's a bookmarklet that produces a link to your Google Calendar event when you are editing its Details page:
javascript:(function(){ try { window.prompt('Shareable link to this event:','https://www.google.com/calendar/event?eid='+document.getElementsByClassName('ep')[0].getAttribute('data-eid')) } catch (e) {alert("Use this bookmarklet to get a shareable link to a Google Calendar event when editing its Details page.")}})()
And a version of this bookmarklet which works with the new (as of 2017) Google Calendar UI:
javascript:(function(){
window.prompt('Shareable link to this event:',
'https://www.google.com/calendar/event?eid='+
window.location.href.split("/").pop().split("?")[0])
})()
(Also possibly useful, how to link to a specific day of a public Google calendar:
https://www.google.com/calendar/embed?src={calendar-id}&mode=day&dates={yyyymmdd}%2F{yyyymmdd}
where {calendar-id} is the calendar's id and {yyyymmdd} is the day you want to link to.
Optional parameters include the time zone and whether to display various items, for example:
&ctz=Asia/Taipei&showNav=0&showPrint=0&showCalendars=0
Example: link to single day of a public calendar.)
Here is the HTML to build the link:
https://www.google.com/calendar/render?action=TEMPLATE&text=Your+Event+Name&dates=20140127T224000Z/20140320T221500Z&details=For+details,+link+here:+http://www.example.com&location=Waldorf+Astoria,+301+Park+Ave+,+New+York,+NY+10022&sf=true&output=xml
Event URL is not calendar URL.
This link brings explanations: Google Calender v3
And the way to build this url is:
GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId
where calendarId & eventId are parametres.
Hope this is helpfull.
I wanted to post this because it is tangental to the question being asked and this post comes up when I was trying to do the following.
I was trying to generate a Google Event for the sole purpose of being added to other people's calendars, not saved to any particular calendar. I've found an example here and I'm currently trying to figure out the URL params it accepts.
https://www.google.com/calendar/render?action=TEMPLATE&text=PRP+Due&dates=20141106T120000Z/20141106T120000Z&details&location&trp=false
To view Google calender event by event Id.
You can use below example:
https://www.google.com/calendar/event?eid={event-id}&ctz={timezone}
Example For Indian TimeZone :
https://calendar.google.com/calendar/event?eid=ZjVicWczYWpndmh0ZmdtYmd0cXFxZWc3czggdTJoZmoybGg0aDcwbmhzMzV2c25pamd1dG9AZw&ctz=Asia/Kolkata
To create a page where users can view the Calendar of Events publicly, a user who has permissions to change calendar sharing settings must first make the calendar public:
From the Google Calendar, at the top right, click the Settings wheel.
In Settings, click the "Calendars" tab.
Click the name of the Calendar you're working with.
Next, click the "Share this Calendar" tab. Make sure the checkboxes are checked from the screenshot below (circled in red).
Afterwards, click the "Calendar Details" tab, located at the top left.
Scroll down to the "Calendar address" section, as shown in the screenshot below.
Click "HTML".
A popup modal will appear, which includes the public URL you'll need to access the Calendar publicly.
Here is an example of what the URL might look like:
https://www.google.com/calendar/embed?src=domain.comrandomstring#group.calendar.google.com&ctz=America/Los_Angeles&gsessionid=OK
In addition, see the Google Calendar Data API for information on creating and working with Calendar Gadgets.
To get the event from the Google Calendar API v3, call:
GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId
The event contains a property htmlLink, which is exactly what you need:
An absolute link to this event in the Google Calendar Web UI. Read-only.
See https://developers.google.com/google-apps/calendar/v3/reference/events.
The link looks like this:
https://www.google.com/calendar/event?eid=XzYwcTMwYzFnNjBvMzBlMWk2MG80YWMxZzYwcmo4Z3BsODhyajJjMWg4NHMzNGg5ZzYwczMwYzFnNjBvMzBjMWc2c28zMmRoaDhwMGpnaDIxNnQyNDZkaGc2NG8zMGMxZzYwbzMwYzFnNjBvMzBjMWc2MG8zMmMxZzYwbzMwYzFnNzByNDRoMWk2b3AzOGUxazZoMms2aDFrNmQwamNkaTI2OHBrMmhpMjg4czRjZ2hoNzBwMF8yMDA2MDUwNSBob3BtYW4ubmxfbjE5ZGF2YWgxb3Zkb3EzbGl2N2t1aWU5Z.
It will open the event full screen, only of course if you have access to the event. The screen will contain a back button to go back to the calendar.
Clearly, you can't construct this link yourself so you will need to do a call to the API, but you are probably already doing that anyway.
When an google calendar event created, then in the response we got result property. In this result property, one more htmlLink would be available which have link regarding the event being created. Now, it can opened :
window.open(response.result.htmlLink, '_target');
Wordpress + ACF google cal.
Set your ACF date picker to custom return Y-m-d g:i a
Then create a google formatted date.
$event_start_date = get_field('event_start_date');
$event_print_date = date('d/m/Y',strtotime($event_start_date));
$event_start_time = get_field('event_start_time');
$event_end_date = get_field('event_end_date');
$event_print_enddate = date('d/m/Y',strtotime($event_end_date));
$event_end_time = get_field('event_end_time');
$calendarDate = date('Ymd',strtotime($event_start_date)) .'T'. date('Hi',strtotime($event_start_time)). '00/' . date('Ymd',strtotime($event_end_date)) .'T'. date('Hi',strtotime($event_end_time)) . '00';
Link
Add this event to my Google Calendar
private string GetEventLink(string calendarId, string eventId)
{
var calendarIdToEncode = calendarId.Substring(0, calendarId.IndexOf("#", StringComparison.Ordinal) + 2);
var eId = Convert.ToBase64String(Encoding.UTF8.GetBytes(eventId + " " + calendarIdToEncode));
return $"https://www.google.com/calendar/event?eid={eId.Substring(0, eId.Length - 2)}";
}
Google Have created a page to DIY.
https://support.google.com/calendar/answer/3033039

What's the correct way to listen for a Google+ Hangout state change?

The Hangout API at https://developers.google.com/+/hangouts/writing includes an example to set a callback function when the hangout state has changed, like this:
gapi.hangout.onStateChanged.add(onStateChange);
When run, this results in an error similar to "gapi.hangout.onStateChanged is undefined". A quick check in Firebug shows that the onStateChanged method belongs to gapi.hangout.data not gapi.hangout.
What is the correct way to add a callback function when the state has changed?
The method that you're looking for is indeed a member of gapi.hangout.data. The writing article you mention seems to be out of date. I fix it :)
To do something when state changes just attach a callback:
gapi.hangout.data.onStateChanged.add(function() {
console.log(gapi.hangout.data.getState());
});
You can find working examples of the code in action on the sample apps page.

Resources