Get the date in which an email was sent | XM Community
Question

Get the date in which an email was sent

  • 22 February 2020
  • 5 replies
  • 121 views

Userlevel 3
Badge +11
  • QPN Level 2 ●●
  • 35 replies
Qualtrics automatically generates Start Date, which consists of the date in which the respondent started the survey, but I need the date in which the corresponding email was sent. Most of the time the start date and sent date will be the same, but if the respondent answers the survey the day after it was sent, they will be different. The easiest way would be to add a field to our databases with the sent date, but suppose that isn't an option at the moment. Is there a way (using Javascript for example) to get the date in which an email was sent when a respondent starts the survey?

5 replies

Userlevel 7
Badge +27
Qualtrics keeps track of survey distributions to contacts. So, you could add a web service to your survey that uses the API to get the distribution date and time for your survey and return it as an embedded data variable. The API will be different depending on if you use XM Directory or Research Core Contacts.
Userlevel 3
Badge +11
Thanks @TomG , I looked through the API and what I found that could be useful would be the search contact POST: https://api.qualtrics.com/reference#directory-contacts-search

In that case, for a given respondent I would have to search for it by it's email, and grab LastEmailDate or LastInviteDate. The only problem I see with that is that this directory contact will have several hundreds of thousands of contacts, and if the time to search for a contact grows linearly with the size of the directory, it can turn very inefficient. Is there another way to do this?
Userlevel 7
Badge +27
> @AxelS said:
> Thanks @TomG , I looked through the API and what I found that could be useful would be the search contact POST: https://api.qualtrics.com/reference#directory-contacts-search
If you are doing this from a web service call in the survey, you already know the contact (RecipientID), so you don't need to search for them. Contacts search doesn't return the info you need. Use Get Contact History: https://api.qualtrics.com/reference#get-contact-history (assuming you are using XM Directory).
Userlevel 3
Badge +11
> @TomG said:
> > @AxelS said:
> > Thanks @TomG , I looked through the API and what I found that could be useful would be the search contact POST: https://api.qualtrics.com/reference#directory-contacts-search
> If you are doing this from a web service call in the survey, you already know the contact (RecipientID), so you don't need to search for them. Contacts search doesn't return the info you need. Use Get Contact History: https://api.qualtrics.com/reference#get-contact-history (assuming you are using XM Directory).
>
>

I tried that API call but I get a list like this:

!

and I don't know how to grab always the last value (if it's even possible). Instead I tried using Get Directory Contact (https://api.qualtrics.com/reference#get-directory-contact) and retrieving LastInviteDate, but I couldn't manage to make it work on the survey flow. After some research I found that what was happening was that RecipientID comes with an id like CTR_6Dm3rlBF3KD1NKl (which I think is a transaction id), instead of a contact id like CID_cJcXxj6sAAg68ip. So I think what I would have to do instead is use another api call (Get Contact Transaction) to get the transaction info and from there I could get the date (transactionDate), right?

One more question: the transactionDate is in this format 2020-02-24 17:49:15, but i need it like this: 24-02-2020, do you know how could I transform it?

Thank you so much for your help!
Userlevel 7
Badge +27
The best thing to do is write your own web service script that does the API call. It would then interpret the results (e.g., filter by a Survey ID you pass it) and send back only the data you are interested in. The script could also transform the date into your desired format.

Leave a Reply