위치
컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
국가를 타겟팅하는 캠페인
function targetFrance(campaignName) { const campaignIterator = AdsApp.campaigns() .withCondition(`campaign.name = "${campaignName}"`) .get(); if (!campaignIterator.hasNext()) { throw new Error(`No campaign with name "${campaignName}" found`); } const campaign = campaignIterator.next(); // Target France (location id = 2250) and set a bid modifier of +50%. See // https://developers.google.com/google-ads/api/reference/data/geotargets // for details. campaign.addLocation(2250, 1.5); }
캠페인에서 타겟팅하는 위치 목록 가져오기
function getTargetedLocations(campaignName) { const campaignIterator = AdsApp.campaigns() .withCondition(`campaign.name = "${campaignName}"`) .get(); if (!campaignIterator.hasNext()) { throw new Error(`No campaign with name "${campaignName}" found`); } const campaign = campaignIterator.next(); return campaign.targeting().targetedLocations().get(); }
캠페인에서 타겟 위치 삭제
function untargetFrance(campaignName) { const campaignIterator = AdsApp.campaigns() .withCondition(`campaign.name = "${campaignName}"`) .get(); if (!campaignIterator.hasNext()) { throw new Error(`No campaign with name "${campaignName}" found`); } const campaign = campaignIterator.next(); // Remove targeting for France (location id = 2250). See // https://developers.google.com/google-ads/api/reference/data/geotargets // for details. const targetedLocationIterator = AdsApp.targeting() .targetedLocations() .withIds([[campaign.getId(), 2250]]).get(); if (targetedLocationIterator.hasNext()) { targetedLocationIterator.next().remove(); } }
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-21(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-21(UTC)"],[[["\u003cp\u003eThese Google Ads scripts demonstrate how to target, retrieve, and remove location targeting for campaigns, specifically using France as an example with location ID 2250.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003etargetFrance\u003c/code\u003e applies a location target (France) and a bid modifier of +50% to a specified campaign.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetTargetedLocations\u003c/code\u003e returns a list of all locations targeted by a given campaign.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003euntargetFrance\u003c/code\u003e removes the location target for France from a specified campaign.\u003c/p\u003e\n"]]],[],null,["Target a campaign for a country \n\n```gdscript\nfunction targetFrance(campaignName) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = \"${campaignName}\"`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name \"${campaignName}\" found`);\n }\n\n const campaign = campaignIterator.next();\n // Target France (location id = 2250) and set a bid modifier of +50%. See\n // https://developers.google.com/google-ads/api/reference/data/geotargets\n // for details.\n campaign.addLocation(2250, 1.5);\n}\n```\n\nGet the list of locations targeted by a campaign \n\n```gdscript\nfunction getTargetedLocations(campaignName) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = \"${campaignName}\"`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name \"${campaignName}\" found`);\n }\n\n const campaign = campaignIterator.next();\n return campaign.targeting().targetedLocations().get();\n}\n```\n\nRemove a targeted location from a campaign \n\n```gdscript\nfunction untargetFrance(campaignName) {\n const campaignIterator = AdsApp.campaigns()\n .withCondition(`campaign.name = \"${campaignName}\"`)\n .get();\n if (!campaignIterator.hasNext()) {\n throw new Error(`No campaign with name \"${campaignName}\" found`);\n }\n\n const campaign = campaignIterator.next();\n // Remove targeting for France (location id = 2250). See\n // https://developers.google.com/google-ads/api/reference/data/geotargets\n // for details.\n const targetedLocationIterator = AdsApp.targeting()\n .targetedLocations()\n .withIds([[campaign.getId(), 2250]]).get();\n if (targetedLocationIterator.hasNext()) {\n targetedLocationIterator.next().remove();\n }\n}\n```"]]