Gigya Job Openings JS

Skip to end of metadata
Go to start of metadata



Stores an object in Gigya's Data Store (DS). 

For security reasons, you may only store objects that are associated with the currently logged-in user, and you may only access fields that have the proper write access. You may use the ds.setSchema from your server applicationto set the write access to "clientModify" for the relevant data fieldsprior to using this method. Learn more in the Storing Data guide.

Note: If you plan on integrating the DS, we highly recommend reading the Data Store Guide.
The DS is a premium platform that requires separate activation. If the DS is not part of your site package please contact your Gigya Customer Engagement Executive or email




The following table lists the available parameters:

dataJSON objectSpecifies the data to store. The data object should be specified as a JSON object complying with the following restrictions:
  • User defined field names must begin with a character and may contain characters, digits and underscores.
  • We highly recommend that you give every field a type specification by appending the type to the field name in the following manner: "_". Valid types are:
    • i - an integer number (may contain 64bit long values as well), allows exact matching or range searches.
    • f - a floating point number, allows exact matching or range searches.
    • s - a string only allows exact matching.
    • t - a full text search field, allows for partial searching based on keywords.
    • b - Boolean.
    • d - a date field, allows exact matching or range searches. The valid date format:
      • Standard ISO 8601 time format (like "2011.07.14T11.42.32.123+3", may be specified without a time at all or without a time zone)
      • "YYYY-MM-DDTHH.MM.SS.sssZ"
  • When the field type is not specified explicitly we will try to auto detect it. Fields that fail auto detection will be considered strings.

For Example:
   firstName_s : "david",
   birthDate_d : "1978-07-22",
   about_t : "I love tracking,...",
   academicDegree : {
       university_s: "Berkeley",
       degree_s: "MBA",
       department_s: "Business",
       courses : [{...}, {...},...]
   hobbies_s: ["running", "music", "movies"]


 When saving data as a nested field, it is important to save the object in the format below:

// Correct
	'a': {
		'b': 'value'

and not as:

// Incorrect

DS always returns an object as it was submitted, this is different than other Gigya schemas, which expand nested objects automatically.

typestring A string indicating the type of the object. The objective of this field is to classify objects of the same type, equivalent to a table name. Different types of objects are searched separately.

An object identifier. The unique identifier of an object is the compound of oid and the current user's UIDThe oid parameter is needed if there are more then one objects of the same type associated with the same user.

*If this parameter is set defined as auto, Gigya will generate an ID for the object. 

A string of maximum 100 characters length. The CID sets categories for transactions that can be used later for filtering reports generated by Gigya in the "Context ID" combo box. The CID allows you to associate the report information with your own internal data. For example, to identify a specific widget or page on your site/application. You should not define more than 100 different context IDs.
A reference to a callback function. Gigya calls the specified function along with the results of the API method when the API method completes.
The callback function should be defined with the following signature: functionName(Response).
The "Response Object Data Members" table below provides specification of the data that is passed to the callback function.
A developer-created object that is passed back unchanged to the application as one of the fields in the response object.
updateBehaviorstringThis parameter defines how to handle conflicting updates. The parameter may receive one of the following values:
  • "arrayPush" (default) - will cause arrays data provided with this API call to be appended to existing arrays data in the DB.
  • "arraySet" - will replace the content of existing arrays data in the DB with the values of arrays data provided with this API call.
  • "replace" - will cause the entire object data in the DB to be replaced with the new data provided with this call.


Response Object Data Members

errorCode integer The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Response Codes and Errors table.
errorMessage string A short textual description of an error associated with the errorCode for logging purposes.
callId string Unique identifier of the transaction, for debugging purposes.
context object The context object passed by the application as a parameter to the API method, or null if no context object has been passed.

Code Sample

// Callback function - print results
function printResult(response) { 
    if ( response.errorCode == 0 ) {  
        alert('User data saved in DB');
    } else {
        alert('Error :' + response.errorMessage);

var params = {
    data: {
          address: {
    type: "extendedInfo",
    oid: "12345",
    callback: printResult 

// Call setUserData method;


  • This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
  • To run the code on your own domain, add your Gigya API key to the gigya.js URL. A Gigya API key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API key.
  • In some cases it is necessary to connect/login the user to a provider ? prior to calling the API method. You can learn more in the Social Login guide.