How to track click event on server side in sitecore - sitecore8

How to track the user click event on the server side in sitecore?
Our requirement is to track few external clicks on the site and register them as goals. I can track the clicks through client side js script but then I would like to achieve this through server side. Any idea as to how to track?
Which event\processor actually holds the clicked links info/?

There are no events and no processors which are execute when a link on a page is clicked.
You have 2 options if you want to register external link click as Sitecore goal:
Add onclick javascript background call to the server and send the information about the link which was clicked. Then register it as a goal on server side.
Create "External link" item in Sitecore and link to that page instead of linking to the external page directly. Then add a goal to that page and instead of displaying it, redirect client to the external site.

A click to an external page will not pass through Sitecore anymore, so the system will not be able to track that ootb. Like Marek said, you have a few options to do this yourself. I wrote a blog post on it (https://ggullentops.blogspot.be/2016/02/integrating-addthis-with-sitecore-goals.html) a while ago explaining (with code) how to do this with javascript on the client and a controller to register the goals on the server.
We just post to the controller which takes care of the triggering the goal. Code in short looks like this (check the post for full code - also with obligatory null checks):
var visit = Tracker.Current;
var page = Tracker.Current.Session.Interaction.PreviousPage;
var registerTheGoal = new PageEventItem(goalItem);
var eventData = page.Register(registerTheGoal);
eventData.Data = goalItem["Description"];
eventData.ItemId = goalItem.ID.Guid;
eventData.DataKey = goalItem.Paths.Path;
Tracker.Current.Interaction.AcceptModifications();
Tracker.Current.CurrentPage.Cancel();

Related

Dialogflow CX | How to let the bot initiate the conversation?

Dialogflow ES has an event called 'WELCOME' which makes it possible for the bot to initiate the conversation.
How can I do the same in Dialogflow CX?
There is no entry fulfillment option in the Start Page of Dialogflow CX.
Edit:
Delete the 'Default Welcome Intent' route.
I am unable to perform this. I get the following error.
In 'Default Welcome Intent' change the intent from 'WELCOME' to nothing.
I get the following error. I have set the condition to true. I have also set the page transition to 'onboarding' page.
Please let me know if more screenshots are required.
To accomplish what you're asking, the easiest way would be to:
Open the "Default Start Flow" and select its Start page.
Remove all routes and add a new one.
This new route takes a "custom condition" in the form of true (in the condition pane, click on customize expression and then just type true) and goes to a new page
called "Onboarding" (on the bottom of the route creation page, click on new page and name it Onboarding).
Go to the Onboarding page and add an entry fulfilment "Hello there, how are you doing today?"
in this way every time the default start flow is activated (window is opened) the bot will use that fulfilment.
EDIT:
ok, i tried creating a new agent and i think i solved the problem.
it seems as though we can't erase the default welcome intent, but it doesn't matter.
i created two pages: onboarding and first page. from start i added an always true route to the onboarding page, and i did the same with the onboarding and first page. As you can see from the testing console we only get the expected behaviour for the second transition, look at this:
start page:
onboarding page:
"first" page:
After looking for info on the documentation i think i understood this: from the testing console, google doesn't let you see the actual behaviour of the conversation. If you see the screenshots, when i say "hi" and go the the onboarding page, i get immediately brought to the next page by that "true" transition. Since the same exact sequence is on the start page, the same behaviour should apply there: you only can't see it in the console because "opening the window" in the console is not the same as opening the conversation "in real life".
So, what i suggest you to do is create a new integration or develop a testing environment for the bot, say a website with the messenger integration, a telephony integration or whatever else, and test this onboarding on there. Speaking from personal experience, try with the messenger one maybe: you get a link and you just embed the script in any webpage (works well and easy).
It should work, as in, as soon as you open the conversation, the bot should go the onboarding page and say "hello there!"
So, I'm not sure what your end use-case is, but DFCX (at it's core) isn't exactly designed to initiate an unsolicited message because it's really just a language model with a bunch of features built on top of it.
With that being said, if you want to create a pop-up window for your website chat-widget, you can actually configure this in the integration settings with your embed code. Here's an example:
//The DF Messenger element:
<df-messenger df-cx="true" chat-title="Agent Name" agent-id="<your agent ID>" language-code="en" expand="true"></df-messenger>
//The window load script :
<script src="https://www.gstatic.com/dialogflow-console/fast/messenger-cx/bootstrap.js?v=1"></script><script>
window.addEventListener('dfMessengerLoaded', function (event) {
const dfMessenger = document.querySelector('df-messenger');
const openText = ('<The Text You Want To Display On Page Load>');
dfMessenger.renderCustomText(openText);
});
</script>
Please note this will only work if you have the DF Messenger Integration enabled on your agent. See the docs for integrating DF Messenger here
1.Use the attribute intent inside the df-messenger tag in your UI/HTML page
2.Then create a Custom Event in Dialogflow CX (By clicking on Event handler '+' icon)
3.Check the 'use custom event' checkbox and provide event name and provide a text response in fulfillment section of this custom event.
4.Finally provide this custom event name as value to the attribute intent(mentioned in step 1)
please refer to this document for df-messenger HTML customizations https://cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger#html-customize
According to Dialogflow CX documentation, the WELCOME event (although not visible in the Start flow) is also available. As you can see in this link and the picture below.
To invoke this event, you have to use the detectIntent method of a Session client. You'll need to specify the event name in queryInput.event.event of the request used in detectIntent.
Hope this helps!

Selenium Python: auto click allow for notification requests

I a have small scraper for Facebook that uses chromedriver.
However every time I login after a couple of seconds I have to click some button to allow Facebook notifications. Is there a way to do it automatically?
I've seen some suggest to press tab three times and then enter but I don't know when exactly I'll be prompted by the request and I don't want to press stuff at the wrong time.
Is there anything that can be one when creating the webdriver?
Most likely, this is because every time you start a new ChromeDriver instance you get an entirely new Chrome profile, just like if you opened a new private browsing session. So all the client specific settings that the page you want to test has defined via cookies will be lost and have to be set again. (The main reason why this is a good thing is that for automated testing, you'd like the page to be in the same state every time a new test visits it.)
There are however ways to emulate cookies for testing with WebDriver.
Example
Consider the page http://www.cnn.com for example. Every time you run a new test against that page, a bar at the bottom of the page will pop up asking you to accept their cookie policy:
The page stores the fact that you once clicked the "I agree" button in a cookie itself. You can use the Chrome content settings to identify which cookies a certain web page sets. Details on that can be found here: https://superuser.com/questions/244062/how-do-i-view-add-or-edit-cookies-in-google-chrome
For this particular page, the name of the responsible cookie is "CNNtosAgreed" and the value it is set to once you click the "I agree" button is "true".
In your WebDriver script you can use the manage cookies functionality to set specific cookies, so that the page you're testing thinks you have been visiting it before.
In the Java client bindings this would look like that:
Java
driver.get("http://edition.cnn.com/");
driver.manage().addCookie(new Cookie("CNNtosAgreed", "true", ".cnn.com", "/", null));
driver.get("http://edition.cnn.com/");
Notice how the first time Chrome navigates to the page, the confirmation dialog pops up, but not the second time.
Here are some examples of what the cookie API exactly looks like in Python: How to save and load cookies using python selenium webdriver

How to detect status of a Like button change outside my page

I am implementing like button in my page an can detect if user likes/unlikes with JS events. Is there a way to detect if user unlikes within Facebook (not from web page). OR a way to detect the status of button when the page first loads?
Not really without asking for app permissions from each user who visits your site and looking at their likes connection via the Graph API.

Web Browser control in C++: Detecting mouse click on specific button

My C++ application is using a web browser (IE) control. I need to detect when the user clicks a button on a specific web page (using the element ID of that button).
How can I do this? I already have an event sink implemented, but I do not know how to catch mouse click on DOM elements.
The event you are looking for is probably related to:
onclick event
But whether this is accessible from the MS IE API from C++ via EventSinks, I don't know.
Other Round-About Way to Get Click Information to Your C++ Code
I am not an expert on it, but companies like UserZoom, analyze the information by inserting Javascript via a plug-in to the web browser. Here is a quote from their FAQ of how they collect the click-streams:
UserZoom FAQ
Data Collection & Tracking
What type of information is UserZoom
capable of tracking during the tasks?
With the plug-in version or non plug-in with JavaScript tracking code,
UserZoom can track participants’ navigation paths as well as where
participants have clicked on pages throughout the tasks (heatmaps).
With the non plug-in version, navigation paths and participant clicks
cannot be captured.
Now with this knowledge, go find a javascript library that can get the clicks and the document object model info.
Google Search: "how to get where the user clicked element in javascript"
How to get the target element when clicked?
StackOverflow: JavaScript: Get clicked element
Then you need to insert that bit of javascript into the webpages into the browser the user is using.
Adding Javascript with an add-on/extension/plugin in Firefox and Chrome is relatively easy, I've heard, but for IE, I think you have your work cut out for you to create the add-on in IE. After much searching I found this:
Inject HTML and JavaScript into an existing page with BHO using MS Visual Studio 2010 and C#
And lastly, get that information out of the javascript and into your code using JSON or AJAX and setting up a local webserver to receive it:
Google Search: receive ajax c++
Jquery Ajax Calling Functions
AJAX and the C++ Programmer
Hopefully that information gives you a starting point. Good luck.

Help with design a facebook integration for my website.. App or Page?

I´m building a website to post my own videos using JW Player running my own ads as overlay.
www.planetsnowmobile.com
All my videos will be
Instead of register my own users, having my own forum etc etc I want to use facebook to interact with my visitors:
Individual discussions/comments on individual films instead of my own comment/forum-function
facebook-like-button for individual films (so induvidual like buttons for individual films)
Share induvidual films
Grab location from every unique visitor
Where do I start?
Do I need to create an application or should I use a Facebook "page"?
Maybe both?
I see that i can add an application to a "page" but what does that really do? How do I use that?
What would be the best way for me to do this?
I already have a Facebook "page" for my website and I just created an App as well.
Which one should I use?
Do I need both?
What is the difference?
I know that I can create a like button for a website address on http://developers.facebook.com/docs/reference/plugins/like/
But can I monitor that like button from example an application if I can connect them somehow?
Is that something I want to do?
My Facebook-page already have a user-base where my Facebook-application does not.. is my best option to delete my "page" and start all over with my "application"?
App is their encompassing term for any application that uses their API, this could be on Facebook or on your own personal website - these require an API key to make authenticated calls for users. Pages are FB's own in-Facebook content that users have created, like page for a business located at facebook.com/mybusiness. It sounds like you already have a website and want to add Facebook functionality to it, so you don't want to make another Page. You may not even need to create an App. Things like comment boxes and like buttons can be dropped in as stand-alone copy-and-paste widgets. You can track the like button by enabling FB insights for your website.
So like you noticed you can add a like button to your page using the social plugin from http://developers.facebook.com/docs/reference/plugins/like/ - similar to the like button you can add comment boxes with the plugin at http://developers.facebook.com/docs/reference/plugins/comments/
You can track the results from these plugins by adding your website to Facebook's analytics (Insights) at http://www.facebook.com/insights/
Most of these things are powered by the opengraph metadata in the headers of your website's pages. You can read up on what tags FB uses here http://developers.facebook.com/docs/opengraph/
Everything at http://developers.facebook.com/docs/plugins/ can be used without an application or page ID, and is very good about being responsive to the page they are hosted on: you can add a like button to your video view template without a defined URL in the like button's parameters, and it will automatically direct any likes to the url of the currently viewed video.
You could also direct a like button to point to your existing FB Page, in which case any likes collected from it would be added to the Page's total. Most companies that have a home-page like button do this, so their likes all accumulate to a single total for their business.
Hope that helps.