Using GA to retrieve metrics from API - node.js

I am trying to use Google Analytics to retrieve metrics from an API.
The thing is, I am not sure to understand how the whole analytics tracking works. I tried to understand how to implement custom metrics and dimensions from this : https://developers.google.com/analytics/devguides/collection/analyticsjs/events but I am still not very sure on how to proceed.
Let us say for instance that I want to send a custom event to Analytics when a client clicks on a button to create a PDF.
Should I write something like :
ga('send', {
hitType: 'event',
eventCategory: 'Project',
eventAction: 'pdf_export',
eventLabel: 'StartOfProject'
});
And put it in the handler of the endpoint route corresponding to the page launched when the button is clicked?
Or do I have to create an event with EventEmitter? I must confess I am quite lost here...
[EDIT] Victor Leontyev showed a very easy way to of it (thank you!), however it was here a rather simple use case. I was also wondering :
If I want to send a custom metric (a ratio...), should I put it in the optional eventValue?
If I want to have the number of PDF (to keep with the same example) per day, how can I do? It would mean I guess that I should launch an event every 24H on a precise hour, and have kept somewhere (in a DB?) the data for the day so I can send it? Can this easily be done?
The other kind of metrics I need would be periods between two actions, lie let us say between the click on the 'Create a new PDF' button and a 'Print the PDF' one. Can it be done with launching a tier on the first button press, then stopping it and the second one and sending the time as the eventValue ? Or is it more complicated?
I warmly thank you once again for any lead/form of hep and support!
Have a nice day,
-- smgr

If you have a button, where users can download your PDF. For example:
Download PDF
And if you want to send event to GA with this data:
eventCategory: 'Project'
eventAction: 'pdf_export'
eventLabel: 'StartOfProject'
All that you need is to change HTML of your button into:
Download PDF
Then you will be able to see how many users click to your Download PDF button in GA (Behavior -> Events or Realtime -> Events)

Related

BotFramework: Create Suggested Actions without text attribute

I'm creating a bot in DirectLine. I'm trying to use SuggestedActions to display a suggested action and I don't want to include the text attribute for that. When I try to run my code without the text attribute, I see a blank message being displayed. How can I avoid that?
My code
var msg = new builder.Message(session)
.suggestedActions(
builder.SuggestedActions.create(
session, [
builder.CardAction.imBack(session, "disconnect", "Disconnect"),
]
));
session.send(msg);
The Output i'm getting:
Per my understanding, you want a button which is shown absoluted at bottom and always display to remind your agent that he can disconnect conversation any time.
However, per me testing and understanding, in my opinion, there 2 points that it's maybe not a good idea to achieve this feature:
SuggestedAction is based on Messasge in Bot framework. And basically Bot application is for conversation. So every message between user and bot renderred in different channels should always be contained in a textbox, shown like in your capture. We cannot bypass this feature.
Per your requirements, I think you want this button should be always display unless the agent click it. But I didn't find any feature like this in Bot framework, and you may need to send this meesage additionally beside every message from bot, which is not graceful and will raise unpredictable risk.
My suggestion is that you can create a triggerAction to handle global disconnect requests. Refer https://learn.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-actions for more info.

How to Customize the NetSuite Calculate Shipping Button

How can I customize the Calculate Shipping button (the calculator icon) on Sales Orders under the Shipping tab? I've written my own app using the UPS API and I would like to fire that instead of the native NetSuite shipping calculator. So how can I make the Calculate Shipping button fire my custom code?
Sorry but there is no way to do that via API. You could hack it but probably more trouble than it's worth.
to make your custom calc work:
Associate it with a shipping method (or methods) that have flat rate of $0. If you don't use $0 then NS will re-apply the flate rate charge at various inopportune times.
when something changes trigger the API lookup OR
add a button on the SO form that you can click.
You can also add buttons various other ways with more or less degrees of control. One way is to include an inlinehtml field containing the html for a button and have a script show that when one of your associated methods is selected. I'd back that up with a save page client or before submit user event script to re-calc the value when needed.
When I've done this sort of thing I've made a hash of the shipping address and item ids and quantities and stored that as a body level field. Then you can re-calc the hash in a before submit event and call your API only when the hash has changed.
An another way would be to add a new button using
form.getSublist('item').addButton(name, label, script);
//button would be added in item sublist section
In your script parameter specify the onclick script, the onclick script would be a client side javascript in which you should be able to get SO lines and then fire a AJAX to your suitelet [even nlapiReuqstURL should work smoothly here] which in turn can make calls to your UPS APIs and fetch the rates from there.
Now, the challenge remains is getting rid of the natural calculate shipping button. Probably, you can make it a zero cost one or make the label of new button more appealing to click over the standard one.

Orchard CMS: Invoking two actions leads to duplicate notifications

Our Orchard application displays two of all notifications that are added to the notification service. So far we have traced the problem and know what is causing it, but are looking for a solution other than the obvious, for reasons I shall now elaborate.
So we are using a number of themes to render our Orchard based application. Within our layout, we have a Razor call to draw a header bar that displays a set of information about the user that is logged in.
#Html.Action("OutOfGameHeader", "Options", new { area = "Area.area.Location.Common" })
This action calls the OnResultExecuting() method in Orchard.UI.Notify.NotifyFilter which (among other things) populates the Messages Zone with the current set of notifications. When we make the call the render the Messages Zone, this same method runs again and the notifications are added to the Zone's shape again resulting in duplicate notification being displayed when the Zone is actually drawn.
Can anyone think of a solution that meets the following criteria:
Drawing the header without calling #Html.Action() to avoid OnResultExecuting() being triggered the first time.
Without creating a new Widget in a new Zone as this would involve us changing the manifest for dozens of existing themes to include it.
We also found this just below the point in the code where the notifications are added to the Zone, so if anyone knows anything more about it, that would be helpful too.
//todo: (heskew) probably need to keep duplicate messages from being pushed into the zone like the previous behavior
//baseViewModel.Messages = baseViewModel.Messages == null ? messageEntries .Messages.Union(messageEntries).ToList();
//baseViewModel.Zones.AddRenderPartial("content:before", "Messages", baseViewModel.Messages);
Any thoughts greatly appreciated.
Avoid Html.Action. This runs through the whole lifecycle as if this was a new request. That you think you need it is often a sign that you need to refactor and extract that logic that you want to re-use out of your controller. In Orchard, it's also better to use dynamic shapes.

How to make a gmail gadget change a message label?

I often use two gmail labels label1 and label2, and according to my personal mail management rules, I often change messages categories from label1 to label2.
As I do this often, I thought I should try to automatize this process a bit by adding custom gmail command.
Here are the specifications of my mini-feature :
1) When a message (according to gmail api, a "thread") labelled label1 is selected in gmail, a button "CHANGE LABEL1 TO LABEL2" should be displayed in my gmail interface
2) When I click this button, selected message's label1 should be removed, while a label2 label would be added
That's it for the features.
Technically, here is what I think is needed :
a) A way to get and set the labels attached to a given message thread (identified by an id)
b) A way to display a button conditionally
c) A way to trigger a script when the button is clicked
d) A way to detect the id of selected message thread
Here are the technical solutions I think are available for each part :
a) ...is possible via a Google Apps Script, using GmailThread::addLabel and GmailThread::removeLabel
b) ...seems possible via a contextual gadget
c) ...is my first concern, since clicking on the button from b) should launch the script from a)
Also, the call to the a) script should pass the message thread id as a parameter.
d) ...is my second concern, maybe is it also possible via a contextual gadget, since those can parse the contents of a message ?
Does it seem possible to implement this mini-feature given the actual technology provided by google for scripting ?
More precisely, is it possible to make Gmail Gadgets and Gmail Apps Scripts interact ?
Or are there some alternatives to implement it ?
Additional information : I tried to investigate other technologies provided by Google to customize its product, but it seems that Gmail Labs API is not open to the public. Also, I don't think I could use a Gmail Sidebar Gadget since they do not seem to be able to know which message is currently selected in the gmail interface.
I don't know if you can use a contextual gadget this way but you may write a simple script (time triggered) who search for threads with a third label (or one of the stars) used by you as an indicator of your will to toggle labels...
The script search the threads you mark and toggle labels (than remove the mark) ...
Pretty easy ...
I do something similar at the moment using a contextual gadget. The only way I know to change the labels is via IMAP. My gadget passes the details of the email to my server which uses IMAP to connect to email message and change its label. Although this seems a long winded way of doing this I think it is your only option.

How should an IPhone notification-type application show user there is a notification unobtrusively

I have a program that basically just queries a webservice, and if any data is returned it will show that information to the user, but if there is nothing to display it will just wait until the next scheduled time and run.
Right now it just puts a table in front of the user, there is nothing in the status bar that they can then select and see the actual information.
So, I have two questions.
Is there a better way to show
notification information to a user
that is less intrusive?
Should the View, with a UITable,
have a button to dismiss the view
when they are finished?
UPDATE:
It seems my question isn't clear enough, so I have the data showing up in the table properly.
My problem is before I display the data.
Currently, periodically the timer will fire off my method, and if there is any events pending for the user the table will show up right in front of them.
That is bad design, IMO, so what I would like is some simple way to let them know that there is something pending and they can look at it when they get a moment.
Ideally I would have something in the status bar to show that they have some events, but it appears that isn't an option that I can see.
One option is to see if I can have the table come up minimized and have some sound or vibration go off, but again that can be bothersome to the user, as it may interrupt what they are doing.
The proper solution appears to be that while in the background just put up a notification if there is any new information, so the user can close the notification or switch to view the details.
This isn't the ideal solution, but appears to be the best choice on the iPhone.

Resources