Events sent with Measurement Protocol do not set active users - google-analytics

I am trying to send events from a Telegram bot (Java backend) to Google Analytics using Measurement Protocol V4. The event currently looks like this:
{
"client_id": "<telegram_chat_id>",
"events": [
{
"name": "tg_bot_command",
"params": {
"command_type": "HELP"
}
}
]
}
After the event is sent, I see the event and its property on the real-time overview page in the "Event count by Event name" card, but the client_id property is nowhere to be seen. And the "Users in last 30 minutes" card remains empty.
I also tried adding the user_id parameter to the events, but it also had no effect.
How do I send those events so that they show that users are active?
G-Analytics page showing logged events, but no users

Solution: add engagement_time_msec to event properties

Related

Track Custom event using Google Analytics

I am trying to track user feedback onclick of thumpsUp(1) or thumsDown(0) : with help of GA but not able to track the events in the Analytics Dashboard as shown below.
window.ga("send", {
hitType: "event",
eventCategory: "button",
eventAction: "feedback",
eventLabel: pageID, // page url
eventValue: value, // 1 or 0
});
}
custom event is not appearing below:
I am able to get events :
Is it possible to map vote and pageID together so that we can know which page has which vote
Many Thanks
The code shown is for Universal Analytics but dashboard is on GA4.
They are 2 different things.
You can find code to setup GA4 events in the documentation: https://developers.google.com/analytics/devguides/collection/ga4/events?client_type=gtag
To understand who clicked on up/downvote you can use the parameters associated with the event:
https://developers.google.com/analytics/devguides/collection/ga4/event-parameters?client_type=gtag
Note: the data in the GA4 platform (unlike UA) are visible after 24h.

Google analytics events not visible in dashboard

I'm trying to track clicks on the page. I have added GA script to my page and I can see the traffic. The next step is to track click on given button. I have added following script to my buttons:
onclick=gtag('event', 'Click g-store top', {
'event_category' : 'ButtonClick',
'event_label' : 'Click to google play'
});
I can see the events flowing to my dashboard under "Realtime" label as events in last 30min.
But I can't see them in more persistent way under Engagement -> Events. What am I missing ?
As stated by Michele Pasani, you need to wait at least 12-24h until the events show up in the "All events" page

Tracking user link clicks with google analytics

I have created an affiliate marketing website. Here users will register on my website and shop, however the shopping link will be of amazon.
I need to know how to set up Google Analytics so that it can track which registered user has clicked an affiliate link on my website.
For example I have this amazon link
https://www.amazon.in/BassHeads-225-Super-Extra-Headphones/dp/B01M9C51T9/ref=sr_1_1?_encoding=UTF8&pf_rd_i=desktop&pf_rd_m=A1VBAL9TL5WCBF&pf_rd_p=14ffe21a-e5a2-45c9-a9c0-91f47b082bbc&pf_rd_r=94G5Y8CM93G8M5Y2SNS3&pf_rd_t=36701&qid=1554008093&s=gateway&smid=A14CZOWI0VEHLG&sr=8-1
I know I'm supposed to put an onClick event on there somewhere but I don't have any idea how it links to Google Analytics? I am using Google Tag Manager
Is this the correct Onclick code:
onClick="_gaq.push(['_trackEvent', 'Link', 'Click', 'Banner Advert1']);"
If not what do I need to add to track the registered user?
I have many links to external sites on my website; an example link looks like this:
<a id="Buy" data-itemDescription="(a description)" data-itemValue="2.80" href=http://externalsite?id=6789>
The key things here are the extra attributes before the href: id (used to identify the specific event that occurs when the link is clicked, i.e. in this case a Buy event) and the data-itemDescription and data-itemValue metadata (used in constructing the event label etc.)
The relevant GTM artefacts are as follows:
Trigger:
Buy: Click - Just Links when Click Id contains Buy
User-defined variables (custom Javascript):
ItemDescription:
function() {
return {{Click Element}}.getAttribute("data-itemDescription");
}
ItemValue:
function() {
return {{Click Element}}.getAttribute("data-itemValue");
}
ItemValueFloat (100 multiplier used because GA didn't like my decimal places - I then divide by 100 at reporting time to get the right answer):
function() {
return parseFloat({{ItemValue}})*100;
}
Tag BuyClicked is an Event triggered by the Buy trigger as above, with:
Category = Purchase Tracking
Action = Purchase {{ItemDescription}}
Label = {{Page Path}} : {{Click URL}}
Value = {{ItemValueFloat}}
I also have Non-Interaction Hit set True.
The BuyClicked event is then collected by GA, and reportable on from e.g. Google Data Studio, without my having to do anything further.
If you can't add an id or metadata, you could undoubtedly do the same sort of thing more painfully by handling all clicks through a single trigger and then parsing the Click URL via custom Javascript to get granular Categories, Actions, Labels.

How do I send a message to Telegram that includes a button that prompts the user to forward the message?

Many Telegram bots (e.g., #youtube) have a button you can click on to forward messages sent by the bot. When the user clicks on this button, Telegram opens a contact list that lets the user choose who to forward the message to.
How can I send a button like this? The closest thing I can find is forwardMessage but that expects chat_id target ID as a required parameter. But I won't have this target ID until the user selects who they want to forward to.
If you want to share your content to specific chats, you have 2 options:
Option 1
If your bot has inline_mode enabled you can share content via a button that opens a inline_query in the chat selected. Basically, this is how #youtube bot works. To use this method you need to send an inline button with switch_inline_query as a field (documentation).
Example in Javascript:
bot.sendMessage(msg.chat.id, 'Share:', {
reply_markup: {
inline_keyboard: [[{
text: 'Share with your friends',
switch_inline_query: 'share'
}]]
}
})
This is the same example I use in my bot #livecoinbot, set a bitcoin address and use the share button.
Option 2
You can create a normal inline button or just simply send a link in a normal message, that will prompt the telegram client to share the content. Here is how you do it:
https://t.me/share/url?url=[url-to-send-here]&text=[text]
Example: Click here

Google calendars not displaying with Full Calendar

I'm trying to display multiple Google calendars with Full Calendar, like so:
eventSources: [
{
googleCalendarId: 'a.calendar.google.com'
},
{
googleCalendarId: 'b#group.calendar.google.com'
},
{
googleCalendarId: 'c#group.calendar.google.com'
}
]
All three calendars have the same settings and when I view the calendar at https://www.google.com/calendar/embed… I can see events from the different calendars displayed, but when I view my Full Calendar implementation, I can only see events from one of the calendars.
If I comment out the source of the calendar with events, my calendar shows no events.
Do I need to set up different API keys for each calendar? I haven't done anything that specifically ties the calendar that is working to the API key I've set up so far.

Resources