Sitecore Analytics Api - Emails Sent, Open and Click throughs - sitecore

We are using Sitecore 6.5 and we have Email campaigns setup and the emails get triggered automatically at different stages of the signed-up users life cycle.
I have been tasked to get the stats for - total count of emails 'sent', 'open rates' and the 'click throughs'(this is user clicking the link on the email and visiting our site).
Does any one know how this can be done using Sitecore Analytics API. I need to pull this information and display it as a report.
I am new to Analytics and any help will be much appreciated.
Edit:
I will need to display this in a web page as 4 columns they are : date, total emails sent, total emails opened and total emails with click throughs. Hence, if you can point me to the right apis that will great.
Thanks

Jack - In the Sitecore backend, there's an area under the marketing center that has Engagement Plans and this is really where you need to look. Keep in mind one thing.. which is that these have available which specific users.. but it's not going to show the specific "users" in the reports. That's available in the backend but isn't a simple API call at this point.
All the tracking of emails is done with engagement plans and the states. Every email in ECM has a field called Engagement Plan that points to the specific engagement plan that is being used to track things. Browsing to that engagement plan in the content editor or marketing center will bring up a screen where you can see the states in the engagement plan and see how many emails are in what state. The ECM engagement plan includes states for everything from "Queued to be sent" to opened and clicked links and had a productive visit.
There should be an engagement plan in place for every email that you have configured in ECM and depending on the type of email being sent, you can also get to it for email blasts that are in the "Sent" folder by clicking the "monitor behavior". There's also an executive dashboard with shows some stats as well although that's more of a 10000 foot view.

I have found the way to get the data you need but I am using Sitecore version 6.6, but in 6.5 this should be the same.
If you select a message that is in the "sent" folder of an email campaign, you will find a "Monitor Behavior" button in the message preview tab of the item details. This button opens the analytics data dialog that displays the information you need. Now, getting this info in the backend is achieved this way:
//get the message item we need the statistics for
var campaignMessage = Sitecore.Modules.EmailCampaign.Util.GetMessage(itemId);
//FlowDesigner will use the sc_ContentDatabase database
Sitecore.Context.Items["sc_ContentDatabase"] = Sitecore.Context.Database;
//get the flow by plan id
var flow = new FlowDesigner().ItemsToFlow(campaignMessage.PlanId);
Assert.ArgumentNotNull(flow, "flow");
var infos = new Dictionary<string, StateInfo>();
int totalVisitorsCount = 0;
foreach (State state in flow.States)
{
totalVisitorsCount += state.Visitors;
infos[state.Name] = new StateInfo(state.Id, state.Name, (double)state.Visitors, default(double), default(int), string.Empty);
}
foreach (StateInfo info in infos.Values)
info.UsersPct = (totalVisitorsCount == default(double)) ? default(double) : Math.Round((double)((info.UsersTotal / totalVisitorsCount) * 100.0), 1);
TotalUserCount = totalVisitorsCount.ToString();
SentNotCompleted = infos["Send not Complete"].UsersTotal.ToString();
InvalidAddress = infos["Invalid Address"].UsersTotal.ToString();
SoftBouncePercent = infos["Soft Bounce"].UsersPct.ToString();
HardBouncePercent = infos["Hard Bounce"].UsersPct.ToString();
MessageOpened = infos["Message Opened"].UsersTotal.ToString();
ClickedThroughPercent = infos["Clicked Through Message"].UsersPct.ToString();
VisitorBouncedPercent = infos["Visitor Bounced"].UsersPct.ToString();
MessageUnopened = infos["Message Unopened"].UsersTotal.ToString();
This is a slight modification of code that is used by Sitecore to get the statistics data. The modification is that I put the items in a dictionary so I get easily refer them by name, but the calculation logic is not changed.
The states you can get are:
Recipient Queued
Send not Complete
Invalid Address
Soft Bounce
Hard Bounce
Message Unopened
Message Opened
Clicked Through Message
Visitor Bounced
Unproductive Visitors
Productive Visitors
You can show the statistics data in numbers or in percent - respectively using UsersTotal and UsersPct properties of Sitecore.Shell.MarketingAutomation.BusinessObjects.StateInfo.

Related

How do I check the information sent by the GTM event trigger to Recommendations AI project?

Could someone inform what is the most correct way to verify what is the information sent by the GTM event tag screenshot to an Recommendations AI project?
Confirm your triggers are not misfiring by using the preview mode in GTM: https://support.google.com/tagmanager/answer/6107056?hl=en
As Eike mentioned, open the Developer's console Network tab https://developer.chrome.com/docs/devtools/network/
Clear the log in the Network tab. And select All in the Network filters.
Conduct an action that triggers your tag.
In the Network tab, there are now new activity is shown. Select the one that looks like your endpoint and that has a valid response code (it's almost always 200)
Scroll down to the Query String parameters and assess your payload:
Like so:

Amazon QuickSight embedded dashboard - how to cache user session in my webapp (billing and timing concern)

I have embedded Amazon QuickSight dashboard in my web application by using amazon-quicksight-embedding-sdk (followed https://learnquicksight.workshop.aws/en/dashboard-embedding.html).
The user session seems to last many hours as mentioned in https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GetDashboardEmbedUrl.html
When I requested the embed URL directly from my web browser, I could see that it was valid for many hours.
But my web app will request a new embed URL when user restarts it (by closing/reopening tab/browser). Does that mean a new user session was created and billed.
Is it possible to store the embed URL and to reuse it (as long as the user session lasts) for the case the same user closes the tab/browser and open the web app and the dashboard again (of course in the same browser)?
I tried to store the embedURL as a cookies named "embed_url". But calling amazon-quicksight-embedding-sdk.embedDashboard({url: embed_url}) resulted in
"Embedding failed because of invalid URL or authorization code. Both
of these must be valid and the authorization code must not be expired
for embedding to work."
I was sure the embed_url was still valid because requesting it by the browser directly worked.
Which "authorization code" is mentioned in the above error message? What did I miss or is it actually not possible?
Beside the billing concern, I've noticed that the call to get the embedURL took time (more than 5 seconds, eu-central-1) while the embedding took less (3 seconds). I thought I could improve the dashboard loading time by reusing the gotten embedURL. Any comments about the timing? Is it normal or did I do something wrong so that it was so slow? My test dashboard has only 1 diagram with unchanged dataset.
As per the Quicksight Pricing Page, if you're creating an embedded dashboard for a Quicksight "Reader", then you're paying $0.30/session per 30-minute logged-in-session for this Reader.
The validity of the session can be set in the SessionLifetimeInMinutes parameter of the GetDashboardEmbedUrl API, and has an upper bound of 600 minutes (10 hours).
As an example, suppose you set SessionLifetimeInMinutes to 600 mins for your Reader user. Also suppose that this user stayed logged in and uses the dashboard for 10 hours continuously, then that would equate to 20 sessions of usage (since the billing is in increments of 30-min chunks). At first glance it would seem that this would cause $0.30/session * 20 session-chunks = $6 to be billed.
However, as per the pricing page, there is an upper bound of $5.00 per month for every Reader. Which means that this Reader can never exceed $5 per month regardless of how many Quicksight sessions (of whatever duration) are created for them. So no matter how many times you call the GetDashboardEmbedUrl API for a given Reader, you're capped to $5/month for this user.
Also of use as to what constitutes a Reader session (from the pricing page):
When does a Reader Session start and end?
A Reader Session starts with user-initiated action (e.g., login, dashboard load, page refresh, drill-down or filtering) and runs for next 30-minutes.
Keeping Amazon QuickSight open in a background browser window/tab does not result in active sessions until the Reader initiates action on page.
But my web app will request a new embed URL when user restarts it (by closing/reopening tab/browser). Does that mean a new user session was created and billed.
I'm not 100% sure about this, but yes I believe a refresh (or open/close) of the tab results in a new session for the same user.
A Reader Session starts with user-initiated action (e.g., login, dashboard load, page refresh, drill-down or filtering) and runs for next 30-minutes.
The above excerpt is from the pricing page. So it does seem that page refresh (and thus another call to GetDashboardEmbedUrl) will trigger a new session for the user.
Which "authorization code" is mentioned in the above error message?
The GetEmbedDashboardUrl API response is a JSON object that looks like this:
{
"Status": 200,
"EmbedUrl": "https://us-east-1.quicksight.aws.amazon.com/embed/f4147cd0d4d_BLAH_BLAH_...",
"RequestId": "c15a7bad-629e-444a-b643-ff3142c9ae41"
}
If you look closer at the EmbedUrl, apart from the dashboard url itself, there are also these query-string parameters:
isauthcode
code
identityprovider
statePersistenceEnabled
potentially: other params too
The code parameter (embedded within the embedUrl) is the "authorization code" that you asked about.
Is it possible to store the embed URL and to reuse it (as long as the user session lasts) for the case the same user closes the tab/browser and open the web app and the dashboard again (of course in the same browser)?
No, that can't be done. As it says in the link you shared:
The following rules apply to the combination of URL and authorization code:
- They must be used together.
- They can be used one time only.
- They are valid for 5 minutes after you run this command.
So the embedURL and its associated auth code can only be used once together. Makes sense since this will prevent MITM replay attacks among other scenarios. Also I actually tried to cache the response and then re-use the embedUrl in case of a cache-hit, since this would improve the end-user experience. But this didn't work - a "replay" of the embedUrl is blocked by QuickSight, as mentioned in their doc.
Any comments about the timing?
This has been our experience also. The GetDashboardEmbedUrl REST API takes around 5-7 seconds (us-east-1) for our app and then the actual embedding takes another 3-5 seconds. Not great, but I don't see a way around this poor user experience as of now.

Beacon scheduling in google beacon dashboard

I'm working with 1 beacon advertising in Eddystone-URL and Eddystone-UID at the same time.
No problem with Eddystone-URL.
With UID, I set up several lines in the google beacon dashboard. With targeting options on all of them.
1 for Monday that opens instagram app, 1 for Tuesday-Sunday 3PM-5PM with a URL. Instagram app for Tuesday-Sunday 12AM-11AM, another URL for some other times of the day and week, etc. Not going into the whole details, it's quite complex.
As an example here is a copy of the raw JSON for one of the lines:
{
"title": "Get a FREE Pop at XXXXXX!",
"url": "https://mybitlylink",
"targeting": [
{
"startTimeOfDay": "15:00",
"endTimeOfDay": "16:59",
"anyOfDaysOfWeek": [
2,
3,
4,
5,
6,
7
]
}
]
}
All my 4 URLs are bitly links so I can track the number of clicks I get on each. I haven't found a way to track the number of Instagram app opens.
I set up all my lines to not be redundant, meaning each line is for 1 unique part of the day and week. I have 15 lines total covering almost every minute of the whole week.
My problem is this: a few minutes after I saved my config, some clicks were registered on all my bitly links, whereas only one was supposed to show. Now - 2-3 hours later, all links still collect clicks, making me think all messages are triggered despite the targeting. What is curious is that each of them is collecting the same amount of clicks. I don't know if the instagram app was also shown because the beacon is installed at a customer site remote from me.
Do you think it could be a bitly click count error or that really 4 messages (+ potentially the Instagram open in app message) are broadcasted by Eddystone-UID?
If you are getting clicks from "Mountainview California" It's Google crawler.
The way these notifications work is before displaying them on your phone, the device connects to a Google resolver to find URL, website name and description and an icon. This resolver crawls your website and caches the details (including the icon image).
This is registered as a hit/click on bitly, and that is what you see :)
And unfortunately it is not possible to get stats for app intents.

Refresh Sitecore index to include CD's

I've written some code to refresh an index when an item is programmatically added to Sitecore. Now as the live system is made up of 1 CM and 2 CD Servers I need my code to also trigger the indexing to be refreshed on the CD Servers (unfortunately my dev machine is just a single box so I can't test this fully). I've looked online but can't find anything about this when triggering a re-index programmatically.
So the question is do I need to write code for this or does Sitecore do this by default and if I do need to write code, does anyone have ideas how I go about this. My current code is below.
ISearchIndex index = ContentSearchManager.GetIndex("GeorgeDrexler_web_index");
Sitecore.Data.Database database = Sitecore.Configuration.Factory.GetDatabase("web");
Item item = database.GetItem("/sitecore/content/GeorgeDrexler/Global/Applications");
index.Refresh(new SitecoreIndexableItem(item));
My config for the index has the remotebuild strategy enabled
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/remoteRebuild" />
As #Hishaam Namooya pointed out in his comment, publishing from master to web should trigger the web index updates out of the box, unless you've disabled something in the configurations.
Note that items won't publish unless they are in a final workflow state, so if you want a completely automated process that creates the item, updates the local index, and then immediately updates the web index, you will also need to update the workflow state to your final approved state and then trigger a publish of the item.

Selecting Categories using API in Amazon MWS

I am developing a integration between a desktop application and Amazon MWS and need to be able to offer users a choice of categories to put the product they are listing into. My problem is that I can't find any way of programmatically getting the current categories from MWS using the API.
Additionally once I have a category reference to use I will need a way to the pull in and add the category specific XML child of ProductData (eg Home, Jewelry, Computers, etc) but they don't seem to be linked in any well defined way. For example, I can't say "if the chosen category is reference nnnnn ask them to populate the Computers specific ProductData", unless I write something myself to map them.
Has anyone else come across these problems and found a workable solution?
Any help appreciated...
I am currently exploring the option of limiting users to only selling products already listed on Amazon but still can't figure out how to pull in the correct category specific XML.
There are various product look-ups but they all seem to work from either my SKU (which will not yet be there) or Amazons ASIN (which I don't yet know)
You can use amazon advertizement api for this.
You have to create account on amazon affiliate programme.From that you have to get security credentials also .
After That go to BrowseNode Tree Page and download root categories list and save it to file or database.From there you get categoryname and their browseNodeId.
Then call BrowseNodeApi to get Child Categories for parent Category.
Please Follow This Link
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ProgrammingGuide.html
code for calling BrowseNodeApi
SignedRequestHelper helper =
new SignedRequestHelper(appConfig["AWSAccessKey"], appConfig["AWSSecretKey"], appConfig["endpoint"]);
string url = helper.Sign("http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&Operation=BrowseNodeLookup&BrowseNodeId=" + value + "&AssociateTag=beginners00-00&Version=2011-08-01");
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
}
and also download SignatureGenerator class HMAC