Since the move to HTML5 I have been trying to find a way to automatically send e-Learning data from Captivate without using the users’ email client. In flash I used the CPGURU email reporting widget and have been unable to replicate it’s functionality with HTML5. Until now. Last month I stumbled onto Marius Craciunoiu blog post about the Mandrill App. With a few tweaks here and there I was able to get emails automatically send from Captivate in HTML5, sending both user variables and Captivates quiz variables.
Once you have downloaded the source files (see big purple button) there are five steps to get this working in your own project:
- Get a free Mandrill API key.
- Insert mailto.html into your Captivate project.
- Set up the variables.
- Edit the email.
- Generate your project.
Step 1: Getting an API key
Getting a Mandrill API key is simple, all you need to do is follow the steps below:
- Sign up to Mandrill by following the link.
- Once you have told them about yourself you will be directed to the dashboard. Here you need to select Get API Keys on the right.
- On the next screen you need to select Add API Key. This will generate an API key.
You can set up multiple API keys and use different ones for different Captivate projects.
Step 2: Getting the mailto.html file into Captivate
Once you have your API key you need to copy it into the mailto.html.
- On line 51 of mailto.html you should see the words Your Key Here. This is where you paste in your API key. Make sure that the key is still in between the two apostrophes and then save the document.
- Now open your Captivate project and go to the slide you want the email to send from.
- Now it is just the case of inserting the mailto.html file as a web object. In Captivate 8 this is done by selecting Objects >> Web from the ribbon.
- In the web object address field type mailto.html. You can also name the web object if you wish.
I use the slide after the quiz results. This is because when I had it on the results slide it sent an email every time I failed as well as passed, this felt like overkill.
When you generate your project you will have to copy the html file into the output each time, unless you edit the Captivate template.
Step 3: Setting up variables
The Captivate project you have downloaded comes with a number of custom variables as listed below.
These variables are set by the user when they enter their information in the text-entry boxes on the first slide. To be able to send these variables you must get these variables out of Captivate and into the mailto.html. This is done on lines 14-38 in the file. Each line follows the pattern:
var NewVariableName = parent.GetFromCaptivate(“CaptivateVariable”);
You can use this structure to get any variable that is in your Captivate project to display in the email.
As the mailto.html file is not technically part of the Captivate project, it is embedded as an iframe, you must use the parent. prefix to access the variables.
Using the custom variables
You can use the custom variables 1-10 however you wish, but I thought I’d share how I use them. I usually giving each variable the default string value of “incorrect”. Then for each question, when the user gets it correct I add an advanced action that assigns the value “Correct” to the relevant variable. This means that you can start to see which questions learners are getting wrong, which is invaluable when it comes to evaluating your course.
Step 4: Editing the email
The chances are that the template I have built isn’t exactly what you want. The good news is that it can easily be edited to show more or less information.
If you want to edit the description that displays before the variable you can. Displayed text will be between two apostrophes. You can add whatever you want. You can even use basic HTML mark-up or style it with CSS.
If you want no description, make sure you delete both apostrophes.
Removing a variable
Removing a variable is simple. You just delete the relevant line in the maito.html file. For example, if you want to remove the time taken variable all you have to do is select all the content on line 75 and delete it.
Adding a variable
The easiest way to add a variable is to copy and paste the line before. This lowers the chance of a coding mistake. Once you have pasted the line in you will need to replace the variable name with the one you want and add a relevant description.
For example, to add the number of correct answers to the email you add this line to the code:
+ ‘<br>Correct Answers: ‘ + correctAnswers
If you want to use a variable that I have not defined then you will have to define it yourself. To do this follow the stucture outlined in step 3.
Adding a variable from Captivate to other fields
You are not limited to having variables in the body of the email only. You can have them in any field. Although you should take care with the email fields as they have to be an email address.
For example, if you want the email subject to change dynamically you can do this by incorporating the project title variable. This is done by overwriting the ‘Email results’ on line 66 with coursename.
You don’t use apostrophes with variables.
Step 5: Generate your project
This needs no explanation, but make sure you copied your mailto.html file into the generated folder. Once you have the copied the files, upload your project to a server and you will start to see the results flying in.
And there you have it, a relatively simple email reporting system without spending a penny, enjoy! If you have any questions leave a comment and I’ll try to get back to you as quickly as possible. Happy emailing.