Impression Share Script

252 views
Skip to first unread message

Erica Geiger

unread,
Jun 24, 2019, 11:48:49 AM6/24/19
to Google Ads Scripts Forum

Hello I am using this script: https://developers.google.com/google-ads/scripts/docs/solutions/bid-to-impression-share 
however is there a way to not have this apply to all keywords but only for a specific ad group? 

Thanks! 

Google Ads Scripts Forum Advisor Prod

unread,
Jun 24, 2019, 12:22:07 PM6/24/19
to adwords-scripts+apn2wqclzchwnmxo...@googlegroups.com, adwords-scripts+apn2wqclzchwnmxo...@googlegroups.co, adwords...@googlegroups.com
Hi Erica,

You can add .withCondition("AdGroupName = 'YOUR ADGROUP NAME HERE'") to the return values of both the functions getKeywordsToRaise and getKeywordsToLower.

Cheers,
Anthony
Google Ads Scripts Team

ref:_00D1U1174p._5001UCZBqg:ref

Erica Geiger

unread,
Jun 24, 2019, 12:28:55 PM6/24/19
to Google Ads Scripts Forum on behalf of adsscriptsforumadvisor
Thank Anthony!

Is this correct?


// Copyright 2015, Google Inc. All Rights Reserved.

//

// Licensed under the Apache License, Version 2.0 (the "License");

// you may not use this file except in compliance with the License.

// You may obtain a copy of the License at

//

//     http://www.apache.org/licenses/LICENSE-2.0

//

// Unless required by applicable law or agreed to in writing, software

// distributed under the License is distributed on an "AS IS" BASIS,

// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

// See the License for the specific language governing permissions and

// limitations under the License.


/**

* @name Bid To Impression Share

*

* @overview The Bid To Impression Share script adjusts your bids and allows you

*     to steer ads in an advertiser account into a desired impression share in

*     the search results. See

*     https://developers.google.com/google-ads/scripts/docs/solutions/bid-to-impression-share

*     for more details.

*

* @author Google Ads Scripts Team [adwords...@googlegroups.com]

*

* @version 2.0.1

*

* @changelog

* - version 2.0.1

*   - Fixed logic when determining which keywords to raise and lower.

* - version 2.0.0

*   - Refactored to target impression share rather than position.

* - version 1.0.1

*   - Refactored to improve readability. Added documentation.

* - version 1.0

*   - Released initial version.

*/


// Ad impression share you are trying to achieve, representated as a percentage.

var TARGET_IMPRESSION_SHARE = 0.5;


// Once the keywords fall within TOLERANCE of TARGET_IMPRESSION_SHARE,

// their bids will no longer be adjusted. Represented as a percentage.

var TOLERANCE = 0.05;


// How much to adjust the bids.

var BID_ADJUSTMENT_COEFFICIENT = 1.05;


/**

* Main function that lowers and raises keywords' CPC to move closer to

* target impression share.

*/

function main() {

 raiseKeywordBids();

 lowerKeywordBids();

}


/**

* Increases the CPC of keywords that are below the target impression share.

*/

function raiseKeywordBids() {

 var keywordsToRaise = getKeywordsToRaise();


 while (keywordsToRaise.hasNext()) {

   var keyword = keywordsToRaise.next();

   keyword.bidding().setCpc(getIncreasedCpc(keyword.bidding().getCpc()));

 }

}


/**

* Decreases the CPC of keywords that are above the target impression share.

*/

function lowerKeywordBids() {

 var keywordsToLower = getKeywordsToLower();


 while (keywordsToLower.hasNext()) {

   var keyword = keywordsToLower.next();

   keyword.bidding().setCpc(getDecreasedCpc(keyword.bidding().getCpc()));

 }

}


/**

* Increases a given CPC using the bid adjustment coefficient.

* @param {number} cpc - the CPC to increase

* @return {number} the new CPC

*/

function getIncreasedCpc(cpc) {

 return cpc * BID_ADJUSTMENT_COEFFICIENT;

}


/**

* Decreases a given CPC using the bid adjustment coefficient.

* @param {number} cpc - the CPC to decrease

* @return {number} the new CPC

*/

function getDecreasedCpc(cpc) {

 return cpc / BID_ADJUSTMENT_COEFFICIENT;

}


/**

* Gets an iterator of the keywords that need to have their CPC raised.

* @return {Iterator} an iterator of the keywords

*/

function getKeywordsToRaise() {

 // Condition to raise bid: Average impression share is worse (less) than

 // target - tolerance

 return AdsApp.keywords()

     .withCondition('Status = ENABLED')

     .withCondition(

         'SearchImpressionShare < ' + (TARGET_IMPRESSION_SHARE - TOLERANCE))

.withCondition(.withCondition("AdGroupName = 'YOUR ADGROUP NAME HERE'")

     .orderBy('SearchImpressionShare ASC')

     .forDateRange('LAST_7_DAYS')

     .get();

}


/**

* Gets an iterator of the keywords that need to have their CPC lowered.

* @return {Iterator} an iterator of the keywords

*/

function getKeywordsToLower() {

 // Conditions to lower bid: Ctr greater than 1% AND

 // average impression share better (greater) than target + tolerance

 return AdsApp.keywords()

     .withCondition('Ctr > 0.01')

     .withCondition(

         'SearchImpressionShare > ' + (TARGET_IMPRESSION_SHARE + TOLERANCE))

     .withCondition('Status = ENABLED')

.withCondition(.withCondition("AdGroupName = 'YOUR ADGROUP NAME HERE'")

     .orderBy('SearchImpressionShare DESC')

     .forDateRange('LAST_7_DAYS')

     .get();

}



erica geiger MARKETING COORDINATOR
ZOLA


STATE OF THE ART LAW FIRM WEBSITES   zolacreative.com
POWERFUL PRACTICE MANAGEMENT   zolasuite.com
THE DIGITAL AGENCY FOR HEALTHCARE  zolainteractive.com


--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/ALdTJzeLph4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/g-7Nt000000000000000000000000000000000000000000000PTM2SP00II5WTdxjSPuPWcEpOhEHEw%40sfdc.net.

Google Ads Scripts Forum Advisor Prod

unread,
Jun 24, 2019, 1:48:33 PM6/24/19
to adwords...@googlegroups.com

Hi Erica,

You will just need to get rid of the extra .withCondition(‘ that you included in the selectors.
 

Regards,


Anthony
Google Ads Scripts Team



ref:_00D1U1174p._5001UCZBqg:ref

Erica Geiger

unread,
Jun 24, 2019, 4:29:25 PM6/24/19
to Google Ads Scripts Forum on behalf of adsscriptsforumadvisor
Right, my fault, quick copy and paste. 

Thanks for everything!



erica geiger MARKETING COORDINATOR
ZOLA


STATE OF THE ART LAW FIRM WEBSITES   zolacreative.com
POWERFUL PRACTICE MANAGEMENT   zolasuite.com
THE DIGITAL AGENCY FOR HEALTHCARE  zolainteractive.com

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/ALdTJzeLph4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages