title: Problem inserting audiences into Google Analytics using Google Script Apps
body: <p>I have a Google Sheet with the information of the audiences that I want to create in Google Analytics. I'm trying to insert that audiences using Google Apps Script, taking the values of the Google Sheet.</p>
  
  <p>When I run my function, I get this error: analytics.management.remarketingAudience.insert; error: invalid accountId: UA-143962394-1.</p>
  
  <p>If I change the orders of the parameters, so the insert function call looks like this: </p>
  
  <pre><code>Analytics.Management.RemarketingAudience.insert(propertyId,accountId,resource2)
  </code></pre>
  
  <p>I get this error: analytics.management.remarketingAudience.insert; error: Parse Error </p>
  
  <p>Do you know what is wrong with my code?</p>
  
  <p>I tried to pass resource parameter as json, object and string but the result was the same.</p>
  
  <pre><code>function createAudience(){
      var data = readSpreadsheetData()
      Logger.log(data)    
      var resource = {
                  name: data.audiences[0].name,
                  linkedViews: [getViewId(data.country)],
                  linkedAdAccounts: [{
                          type: data.audiences[0].type,
                          linkedAccountId: data.audiences[0].linkedAccountId
                  }],
                  audienceType: data.audiences[0].audienceType,
                  stateBasedAudienceDefinition: {
                      includeConditions: {
                          daysToLookBack: data.audiences[0].daysToLookBack,
                          segment: data.audiences[0].segment,
                          membershipDurationDays: data.audiences[0].membershipDurationDays,
                          isSmartList: data.audiences[0].isSmartList
                      },
                  }
              }
      var accountId = data.accountId, propertyId = getPropertyId(data.country)
      Logger.log(resource)
      var request = Analytics.Management.RemarketingAudience.insert(accountId,propertyId,resource)
      request.execute(function (response) { Logger.log(response) });    
  }
  </code></pre>