Profile Script - invalid user input | Community
Skip to main content
Level 2
July 20, 2023
Solved

Profile Script - invalid user input

  • July 20, 2023
  • 1 reply
  • 2202 views

I'd like to create an audience of users that have previous searched 'engineering' on a search engine using profile script. The script I entered had no warnings, but when I went to click 'done', I received an 'invalid user input'. 

 

// Define the profile script function
function searchEngineAudience(profile, searchQuery) {
// Check if the user's search query contains the term "engineering"
if (searchQuery && searchQuery.toLowerCase().indexOf('engineering') !== -1) {
// Add the user to the "Engineering Search Audience" profile
profile.attributes.push('Engineering Search Audience');
}
}

// Define the audience name to be used in Adobe Target
var audienceName = 'Engineering Search Audience';

// Get the search query from the user's browser or search engine parameter ('q' for Google, Yahoo, Bing)
var searchQuery = getSearchQueryFromURL('q');

// Get the current user's profile in Adobe Target
var profile = mbox.getProfile();

// Check if the user has a profile
if (profile) {
// Call the function to check if the user has searched for "engineering"
searchEngineAudience(profile, searchQuery);

// Save the updated profile
mbox.updateProfile(profile);
} else {
// If the user does not have a profile, create a new one and add the audience attribute if applicable
profile = {
attributes: []
};

searchEngineAudience(profile, searchQuery);

// Save the new profile
mbox.createProfile(profile);
}

// Function to extract the search query from the URL parameters
function getSearchQueryFromURL(paramName) {
var urlParams = new URLSearchParams(window.location.search);
return urlParams.get(paramName) || '';
}

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Gaureshk_Kodag

Hi @katherineke ,

 

Profile script does not support some javascript functions/methods. for example - window.location.search

Instead of creating a profile script you can directly pass a profile parameter from launch into target page load call and make use of that to create the audience

1 reply

Gaureshk_Kodag
Adobe Employee
Gaureshk_KodagAdobe EmployeeAccepted solution
Adobe Employee
July 21, 2023

Hi @katherineke ,

 

Profile script does not support some javascript functions/methods. for example - window.location.search

Instead of creating a profile script you can directly pass a profile parameter from launch into target page load call and make use of that to create the audience