我正在尝试修改Google AdWords竞价排名脚本,以便针对我选择的广告组调整关键字出价。现在我正在尝试在数组中使用广告组ID,将其分配给变量“campaignSelector”,然后获取该变量的关键字。以下是我到目前为止的情况。无论出于何种原因,我不断收到错误 - TypeError:无法在对象[AdGroupSelector]中找到函数关键字。 (第24行)。有人可以帮忙吗?
// Ad position you are trying to achieve.
var TARGET_AVERAGE_POSITION = 3;
// Once the keywords fall within TOLERANCE of TARGET_AVERAGE_POSITION,
// their bids will no longer be adjusted.
var TOLERANCE = 0.1;
// How much to adjust the bids.
var BID_ADJUSTMENT_COEFFICIENT = 1.05;
function main() {
raiseKeywordBids();
lowerKeywordBids();
}
function raiseKeywordBids() {
// Condition to raise bid: Average position is greater (worse) than
// target + tolerance
var ids = [2123818938];
var campaignSelector = AdWordsApp.adGroups().withIds(ids);
var keywordsToRaise = campaignSelector.keywords()
.withCondition("Status = ENABLED")
.withCondition("AveragePosition > " + (TARGET_AVERAGE_POSITION + TOLERANCE))
.orderBy("AveragePosition ASC")
.forDateRange("LAST_7_DAYS")
.get();
while (keywordsToRaise.hasNext()) {
var keyword = keywordsToRaise.next();
keyword.setMaxCpc(keyword.getMaxCpc() * BID_ADJUSTMENT_COEFFICIENT);
}
}
function lowerKeywordBids() {
// Conditions to lower bid: Ctr greater than 1% AND
// average position better (less) than target - tolerance
var ids = [2123818938];
var campaignSelector = AdWordsApp.adGroups().withIds(ids);
var keywordsToLower = campaignSelector.keywords()
.withCondition("Ctr > 0.01")
.withCondition("AveragePosition < " + (TARGET_AVERAGE_POSITION - TOLERANCE))
.withCondition("Status = ENABLED")
.orderBy("AveragePosition DESC")
.forDateRange("LAST_7_DAYS")
.get();
while (keywordsToLower.hasNext()) {
var keyword = keywordsToLower.next();
keyword.setMaxCpc(keyword.getMaxCpc() / BID_ADJUSTMENT_COEFFICIENT);
}
}
答案 0 :(得分:0)
// Ad position you are trying to achieve.
var TARGET_AVERAGE_POSITION = 1;
// Once the keywords fall within TOLERANCE of TARGET_AVERAGE_POSITION,
// their bids will no longer be adjusted.
var TOLERANCE = 0.1;
// How much to adjust the bids.
var BID_ADJUSTMENT_COEFFICIENT = 1.05;
function main() {
raiseKeywordBids();
lowerKeywordBids();
}
function raiseKeywordBids() {
// Condition to raise bid: Average position is greater (worse) than
// target + tolerance
var ids = [];
var AdGroupSelector = AdWordsApp.adGroups().withIds(ids);
var adGroupIterator = AdGroupSelector.get();
while (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
var keywordsToRaise = adGroup.keywords()
.withCondition("Status = ENABLED")
.withCondition("AveragePosition > " + (TARGET_AVERAGE_POSITION + TOLERANCE))
.orderBy("AveragePosition ASC")
.forDateRange("LAST_7_DAYS")
.get();
while (keywordsToRaise.hasNext()) {
var keyword = keywordsToRaise.next();
keyword.setMaxCpc(keyword.getMaxCpc() * BID_ADJUSTMENT_COEFFICIENT);
}
}
}
function lowerKeywordBids() {
// Conditions to lower bid: Ctr greater than 1% AND
// average position better (less) than target - tolerance
var ids = [];
var AdGroupSelector = AdWordsApp.adGroups().withIds(ids);
var adGroupIterator = AdGroupSelector.get();
while (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
var keywordsToLower = adGroup.keywords()
.withCondition("Ctr > 0.01")
.withCondition("AveragePosition < " + (TARGET_AVERAGE_POSITION - TOLERANCE))
.withCondition("Status = ENABLED")
.orderBy("AveragePosition DESC")
.forDateRange("LAST_7_DAYS")
.get();
while (keywordsToLower.hasNext()) {
var keyword = keywordsToLower.next();
keyword.setMaxCpc(keyword.getMaxCpc() / BID_ADJUSTMENT_COEFFICIENT);
}
}
}