How to update keyword status,maxCPC and keyword text using google adwords api - google-ads-api

Can anyone tell me how to update the keyword status,keyword text and keyword maxCpc using google adwords api.I am trying the basic example i.e Update keyword but it is not working.
Please let me know the procedure to solve this problem !

I don't know which language do you use, but I've used this C# code to modify keywords states through Google AdWords API:
public void SetKeywordState(long groupId, long keywordId, bool newState)
{
// Make sure your web.config contains correct data (developer token etc.)
AdWordsUser user = new AdWordsUser();
// 1st step - creation of criterion service.
var criterionService = (AdGroupCriterionService)user
.GetService(Google.Api.Ads.AdWords.Lib.AdWordsService
.v201406.AdGroupCriterionService);
// 2nd step - creation of AdGroupCriterion (keyword is criterion)
// and new state assignment
var tgtKwrd = new BiddableAdGroupCriterion
{
adGroupId = groupId,
criterion = new Keyword { id = keywordId },
userStatus = newState ? UserStatus.ENABLED : UserStatus.PAUSED
};
// 3rd step - creation of operation
var co = new AdGroupCriterionOperation
{
#operator = Operator.SET,
operand = tgtKwrd
};
// 4th step - commit keyword changes to Google.
criterionService.mutate(new[] { co });
}
Modification of maxCPC and keywordText is going exactly in the same way.
Also, there are many useful code examples in different languages. In this case I've used this code example from Google libraries.
Hope this helps.

My Client Center -> Select your campaign -> Go to the keywords Tab -> Make changes as needed.
OPTIONAL: try using the AdWords Editor. It is freely available for download. Though I wouldn't really recommend this as its for advanced users.
1) http://www.google.com/intl/en/adwordseditor/

Related

Can't preserve document core metadata (Created By, Modified By) when I import documents to SharePoint Document Library

I'm currently building a tool to migrate from a document management system to use SharePoint Online. The main challenge I'm facing is to preserve the details of document authors and creating time. I have checked bunch of of code online but I didn't get success with any of them.
Here are the approaches I used
SharePoint Rest API
Microsoft Graph API
CSOM (using console application)
Here is the code I have so far in CSOM but I'm still not able to update the Author field
li["Title"] = "Update from CSOM";
li["Created"] = DateTime.Now.AddYears(-5);
li["Author"] = author.Id;
li.UpdateOverwriteVersion();
clientContext.ExecuteQuery();
Any idea for how to do this, or if there is any other approach to achieve my goal?
The code works when I did test in my environment.
using (ClientContext context = new ClientContext("https://xxx.sharepoint.com/sites/lee"))
{
string s = "password";
SecureString passWord = new SecureString();
foreach (var c in s)
passWord.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials("admin#xxx.onmicrosoft.com", passWord);
var author = context.Web.EnsureUser("Lee#xxx.onmicrosoft.com");
context.Load(author);
context.ExecuteQuery();
var _List = context.Web.Lists.GetByTitle("List1");
var li = _List.GetItemById(1);
li["Title"] = "Update from CSOM";
li["Created"] = DateTime.Now.AddYears(-5);
li["Author"] = author.Id;
li.UpdateOverwriteVersion();
context.ExecuteQuery();
}
You will need to update the Author and Editor fields at the same time in order to update the CreatedBy field. If you wish to update additional fields at the same time you can. Using SystemUpdate() does not update the Modified date whereas Update() does update the Modified date. See abbreviated sample below.
FieldUserValue userValue = new FieldUserValue();
User newUser = cc.Web.EnsureUser("newAuthor#xxx.onmicrosoft.com");
cc.Load(newUser);
cc.ExecuteQuery();
userValue.LookupId = newUser.Id;
item["Author"] = userValue;
item["Editor"] = userValue;
item.SystemUpdate();
cc.ExecuteQuery();

How do I set the `search` URL parameter in SAPUI5 OData requests?

I want my SAPUI5 ODataModel to send OData requests of the form
https://<my-server>/<my-service>/<my-resource>?search='lalaland'
There are tons of examples how to add a filter with model.filter(new Filter(...)); but this is not what I want. Filtering means I directly address a certain property with a certain comparator. Searching means I address the resource in general and let the OData service decide which properties to search, and how.
The one thing that seems to be possible is:
model.bindRows(..., { "customData": {"search": "lalaland"}});
But this is also not what I want because that sets the search term once when the model is created, but cannot update it later on when the user enters.
Funnily, SAPUI5's own implementation of the SmartTable performs exactly the kind of query I want - but doesn't reveal a possibility how I could do that without a SmartTable.
Found one solution:
oList = this.byId("list"); // or oTable
oBindingInfo = oList.getBindingInfo("items"); // or "rows"
if (!oBindingInfo.parameters) {
oBindingInfo.parameters = {};
}
if (!oBindingInfo.parameters.custom) {
oBindingInfo.parameters.custom = {};
}
oBindingInfo.parameters.custom.search = sValue;
oList.bindItems(oBindingInfo);
However, I don't specifically like the bindItems part. Looks a bit over-the-top to require this to re-bind the whole entity set again and again. So leaving this question open in case somebody has a better idea.
You can use on bindItems or bindRows depending what control is, something like this:
oList = this.byId("list");
oList.bindItems({path: '/XXXX', parameters : {custom: {'search':'searchstring'}}})
Why does it has to be $search and not $filter?
The OData V4 Tutorial in SAPUI5's Demo Kit uses
onSearch : function () {
var oView = this.getView(),
sValue = oView.byId("searchField").getValue(),
oFilter = new Filter("LastName", FilterOperator.Contains, sValue);
oView.byId("peopleList").getBinding("items").filter(oFilter, FilterType.Application);
},

VTiger Extension Module create custom field for Accounts Module

I'm working on a VTiger 6.4.0 Extension Module that is used to get company data when entering a company name in the Accounts module.
The module is almost finished, i retrieve data from a API and enter them in the input fields using JQuery.
But the problem is that i have some data that is not relative to the existing fields in the account information, so i'm trying to create some new custom fields.
Only i can't seem to figure out how to create a custom field for the Accounts module from within my Extension module.
I googled around and watched some posts on stackoverflow.
I came up with the following part of code, but this doesn't seem to work.
public function addKvkfield(){
$module = new Vtiger_Module();
$module->name = 'Accounts';
$module = $module->getInstance('Accounts');
$blockInstance = new Vtiger_Block();
$blockInstance->label = 'LBL_ACCOUNT_INFORMATION';
$blockInstance = $blockInstance->getInstance($blockInstance->label,$module);
$fieldInstance = new Vtiger_Field();
$fieldInstance->name = 'KvKNummer';
$fieldInstance->table = $module->basetable;
$fieldInstance->column = 'kvknummer';
$fieldInstance->columntype = 'VARCHAR(100)';
$fieldInstance->uitype = 2;
$fieldInstance->typeofdata = 'V~M';
$blockInstance->addField($fieldInstance);
}
The addKvkfield function is being called in the vtlib_handler module.postinstall (Couldn't find any information if this is the right way of doing this within a Extenstion Module)
vtlibhandler:
function vtlib_handler($modulename, $event_type) {
global $log;
if($event_type == 'module.postinstall') {
$this->addJSLinks();
$this->createConfigTable();
$this->addSettingsMenu();
$this->addKvkfield();
$this->updateLabels();
// TODO Handle post installation actions
} else if($event_type == 'module.disabled') {
// TODO Handle actions when this module is disabled.
} else if($event_type == 'module.enabled') {
// TODO Handle actions when this module is enabled.
} else if($event_type == 'module.preuninstall') {
// TODO Handle actions when this module is about to be deleted.
} else if($event_type == 'module.preupdate') {
// TODO Handle actions before this module is updated.
} else if($event_type == 'module.postupdate') {
$this->updateLabels();
// TODO Handle actions after this module is updated.
}
}
Hopefully someone can give me a push in the right direction.
Thanks in advance :)
I managed to succeed in creating the custom fields that i needed in the Accounts Module.
Thanks to the Vtiger Mailing List! :)
What did the trick was a small alteration of the code I've written:
public function addKvkfield(){
$module = Vtiger_Module::getInstance('Accounts');
$blockInstance = Vtiger_Block::getInstance('LBL_ACCOUNT_INFORMATION', $module);
$fieldInstance = new Vtiger_Field();
$fieldInstance->label = 'KvKNummer';
$fieldInstance->name = 'kvknummer';
$fieldInstance->column = $fieldInstance->name; // Good idea to keep name and columnname the same
$fieldInstance->columntype = 'VARCHAR(100)';
$fieldInstance->uitype = 1; // No need to use 2 anymore. Setting "M" below will introduce the Red asterisk
$fieldInstance->typeofdata = 'V~O';
$blockInstance->addField($fieldInstance);
}
The above code will create a (optional)Custom Field in the Account module.
If your writing a new module and never installed this module before you can just call the function in the vtlib_handler as i did in my question.
But in my case this did not work because I've already installed the plugin before adding the code to create the customfields.
So what i needed to do is call the function above on the vtlib_handler module.postupdate (this will add the custom field on a module update)
Only problem with this is that it'll get run every time the extenstion is updated.
So i suggest creating a if statement in the function to check if the field already exists in the vtiger_field dbtable if not run the script.
Hopefully i saved someone else some time by writing this all down :P
Goodluck!
Please refer below link
Add New Field in existing Module
Copy code from My Answer and create a new PHP file with ay name. Place that in CRM's root directory and Run into browser. Your Field will be added into your Module. You have to make sure about the parameters you set in code which you copy.

Creating Remarketing list with tracking code already on website

I am trying to use the Remarketing feature for the first time. I have got the Remarketing code from Adwords and placed it on the website.
Looking through the examples; i have garnered the below flow.
With #2 i can associate one of my Userlist with a predefined Adgroup to be shown during Remarketing. My question is how do i link the tracker ID that i have received (looks like var google_conversion_id = 9925XXXXX) with the code below? where is this linking done? UserListConversionTypes and BasicUserList both have ID's; am i supposed to set any of those or this is done automatically?
Any pointers/help will be appreciated.
Please also let me know if you fine any issue with the code below.
set up remarketing using the AdWords API in two steps:
Create a remarketing list.
Create a CriterionUserList to tie your list to an AdGroup.
1.Create a remarketing list
Creating a remarketing list involves the creation of two separate entities: the RemarketingList itself and its associated UserListConversionTypes also known as remarketing tags.
The following code shows how to create a remarketing list.
AdWordsServices adWordsServices, AdWordsSession session) throws Exception {
// Get the UserListService.
AdwordsUserListServiceInterface userListService =
adWordsServices.get(session, AdwordsUserListServiceInterface.class);
// Get the ConversionTrackerService.
ConversionTrackerServiceInterface conversionTrackerService =
adWordsServices.get(session, ConversionTrackerServiceInterface.class);
UserListConversionType conversionType = new UserListConversionType();
conversionType.setName("Mars cruise customers #" + System.currentTimeMillis());
// Create remarketing user list.
RemarketingUserList userList = new RemarketingUserList();
userList.setName("Mars cruise customers #" + System.currentTimeMillis());
userList.setDescription("A list of mars cruise customers in the last year");
userList.setMembershipLifeSpan(365L);
userList.setConversionTypes(new UserListConversionType[] {conversionType});
// Create operations.
UserListOperation operation = new UserListOperation();
operation.setOperand(userList);
operation.setOperator(Operator.ADD);
UserListOperation[] operations = new UserListOperation[] {operation};
// Add user list.
userList = userListService.mutate(operations).getValue()[0];
2.Tie a remarketing list to an AdGroup
A new type of criteria object called CriterionUserList is now part of v201008. Through this type of criteria you are able to tie a UserList to an AdGroup. As with other types of
criteria, this type is also managed through the AdGroupCriterionService. The following code shows you how to create a CriterionUserList and tie it to an existing AdGroup.
// Create user list criterion.
CriterionUserList userListCriterion = new CriterionUserList();
userListCriterion.setUserListId(userListId);
// Create biddable ad group criterion.
BiddableAdGroupCriterion biddableCriterion = new BiddableAdGroupCriterion();
biddableCriterion.setAdGroupId(adGroupId);
biddableCriterion.setCriterion(userListCriterion);
// Create operation.
AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
operation.setOperand(biddableCriterion);
operation.setOperator(Operator.ADD);
AdGroupCriterionOperation[] operations = new AdGroupCriterionOperation[] {operation};
// Add keywords.
AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);
Thanks,
-Devraj
Those two examples from Google pretty much cover how it's set up
The linking is done behind the scenes by Google - they match the ID in YOUR remarketing tag (which is usually specific to one AdWords account) with your remarketing lists (which are again at account level).
You can have many remarketing lists with varying criteria (visited certain URLs on your site, converted, etc. & combinations thereof) and link one of those lists to your campaign or adgroup.
I'd maybe suggest doing this through the AdWords web user interface first time so you understand the process you are automating with the API
You can get all existing conversion trackers as below.
ConversionTracker theConversionTracker = null;
Selector conversionTrackerSelector = new Selector();
conversionTrackerSelector.fields = new string[] { "Id", "Name" };
ConversionTrackerPage conversionTrackerPage = new ConversionTrackerPage();
try
{
ConversionTrackerService conversionTrackerService = (ConversionTrackerService)adWordsUser.GetService(AdWordsService.v201502.ConversionTrackerService);
conversionTrackerPage = conversionTrackerService.get(conversionTrackerSelector);
if (conversionTrackerPage != null && conversionTrackerPage.entries != null && conversionTrackerPage.entries.Length > 0)
{
//iterate over conversionTrackerPage.entries and write down the Id of the convertion tracker you need
}
}
catch (Exception ex)
{
}
Then you can use the Id when creating the conversion type
UserListConversionType conversionType = new UserListConversionType();
conversionType.name = "My conversion type name";
conversionType.id = 19XXXXXXXXL; // The Id you wrote down.

Tab Groups - Any API

Is there any way to use the high-level APIs to detect whether a tab is in the active Panorama group? It seems there's no mention of the tab group a tab belongs to in the tabs module, at least.
Currently there are no plans to provide a tab group api - the 'panorama' feature in Firefox has not proved to be very popular, so there may not be much benefit vs focusing on other features.
Actually there is a way.
I don't know how to get the XUL tab with the SDK, but I know it's possible as I recall people posting questions that did this. Maybe #canuckistani you can help us get the xul tab.
Anyways once you have the tab then you can access it's property _tabViewTabItem. And from here you can do whatever you want. Like figure out the group id of the tab by going tab._tabViewTabItem.parent.id Or change group id's.
Here is some code, the first two lines are non-sdk code.
var tab = gBrowser.tabContainer.childNodes[10]; //non sdk code
gBrowser.selectedTab = tab; //non sdk code
console.log(tab._tabViewTabItem.parent.id) //works both in sdk and non-sdk
Note: pinned tabs dont have the _tabViewTabItem property. So thats how you can tell if its pinned.
var tabs = gBrowser.tabContainer.childNodes;
for (var i=0; i<tabs.length; i++) {
try {
console.log(tabs[i]._tabViewTabItem.parent.id);
} catch(ex) {
console.warn('tab ' + i + ' ex:', ex);
console.log('its probably pinned')
}
}
The Tab Groups extension stores it's data using SessionStore.
var tabData = JSON.parse(SessionStore.getTabValue(tab,"tabview-tab"));
console.log(tabData.groupID); // 3
Data about the groups themselves is stored on the browser.xul object (ie. ownerGlobal). Data specific to each group is stored as "tabview-group" and other data is stored as "tabview-groups".
var groupsData = JSON.parse(SessionStore.getWindowValue(tab.ownerGlobal, 'tabview-groups'));
console.log(groupsData); // Object { nextID: 4,
activeGroupId: 3,
activeGroupName: "Third Group",
totalNumber: 2 }
var groupData = JSON.parse(SessionStore.getWindowValue(tab.ownerGlobal, 'tabview-group'));
console.log(tabData[3].title); // Third Group

Resources