Text Ad Builder Script

Script zur Generierung optimierter AdWords Textanzeigen

Text Ad Builder Script illustration

Erstellen Sie Anzeigen schnell und einfach

Das “Text Ad Builder” Script generiert Textanzeigen basierend auf externen Spreadsheets. Als Datenquelle können Sie den Output unseres “Shopping Explorer” Scripts oder ein beliebiges Spreadsheet nach dieser Vorlage verwenden. Essentiell sind die Spalten “ad text”, “price”, “url”, “item id” und “cpc”. Wir empfehlen Ihnen jedoch die Verwendung des “Data Exploration” Spreadsheets, welches erfolgreiche Shopping Suchanfragen aufzeigt, die sodann als Keywords eingebucht werden können — eine Lightversion von Keyword Sourcing also. Die erfolgreichen Suchanfragen werden je nach Länge außerdem in der Headline 1, Headline 2 und/oder Description verwendet. Zusätzlich kann der im Spreadsheet festgehaltene Preis als adParam verwendet werden.

Gratis AdWords-Script herunterladen

Unverbindlich Potenziale entfesseln

Lesen Sie unsere Datenschutzrichtlinien.

Success image

Vielen Dank!

Nach unten scrollen und Script Code erhalten

Arrow down icon
/**
 * Text Ad Builder Script        . * ・ 。゚☆━੧[ ✪ ᗜ ✪ ]⊃
 *
 * Overview: Close the automation circle by building text ads from the hidden
 * gems in your Google Shopping account. This script generates text ads based on
 * an external spreadsheet. We suggest the prior use of our “Shopping Explorer”
 * script to identify successful Shopping queries which can then be used as
 * keywords and in the ad text.
 *
 * Author: smec Team [smarter-ecommerce.com]
 *
 * Version: 1.0
 * Changelog:
 * - version 1.0
 *  - Released initial version.
 * Updated: 9-05-2018
 *
 * Twitter: @smec
 * Email: [email protected]
 * (c) Smarter Ecommerce GmbH. All rights reserved.
 * License: MIT
 */

/* ============================== Configuration ============================= */

//adjust the textAds to your needs in the textAdBuilder-section marked below

// Campaign you want the Adgroups and TextAds to be created in
var CAMPAIGN_ID = "YOUR_CAMPAIGN_ID";
// Google-Spreadsheet where the exploration-script saved the item-data
var SPREADSHEET_ID = "YOUR_SPREADSHEET_ID";

// Fallback ad title in case the query from the source is too long.
var FALLBACK_HEADLINE_PART_1 = "YOUR_FALLBACK_HEADLINE_PART_1_HERE";

// Sets the second part of the new ad's headline to the specified value.
var HEADLINE_PART_2 = "YOUR_HEADLINE_PART_2_HERE"; //(e.g. "Buy now at our store")

// Adds additional text to the new ad's description.
// Additionally to this text, the script appends AdParam with price at the end.
var DESCRIPTION_ADDITION = "YOUR_DESCRIPTION_ADDITION"; // (E.g. " by BrandName. Buy now for ")
var CURRENCY_FOR_ADPARAM = "€";
// Example final ad description: <Search query> by BrandName. Buy now for 25€ !

// Sets the first path that appears with the new ad's displayed URL.
var PATH_1 = "YOUR_PATH_1"; //(E.g. Soccer)
var PATH_2 = "YOUR_PATH_2"; //(E.g. Store)

/* =============================== Execution ================================ */

function main() {
  var spreadsheet = SpreadsheetApp.openById(SPREADSHEET_ID);
  var data = spreadsheet.getDataRange().getValues();

  var campaignIterator = AdWordsApp.campaigns().withIds([CAMPAIGN_ID]).get();
  if (campaignIterator.totalNumEntities() > 1) {
    throw new Error("Provided an invalid number of Campaign Ids");
  }

  while (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    for (var i = 1; i < data.length; i++) {
      var cpc = parseFloat(data[i][11]);
      if (cpc !== undefined && cpc > 0) {
        var query = data[i][3];
        var itemId = data[i][2];
        var adGroupName = itemId + " - " + query;

        var checkAdGroup = campaign.adGroups()
          .withCondition("Name = '" + adGroupName + "'").get();

        // Check if adGroup already exists.
        if (checkAdGroup.totalNumEntities() === 0) {
          var adGroupOperation = campaign.newAdGroupBuilder()
          .withName(adGroupName)
          .withCpc(cpc)
          .build();
          var adGroup = adGroupOperation.getResult();
          var keywordOperation = adGroup.newKeywordBuilder()
          .withText(query)
          .withCpc(cpc)
          .build();

          var keyword = keywordOperation.getResult();
          keyword.setAdParam(1, data[i][9] + CURRENCY_FOR_ADPARAM);

          // Build text ads
          if (query.length < 30) {
            // Default case (query is below 30 symbols).
            adGroup.newAd()
            .expandedTextAdBuilder()
            .withHeadlinePart1(capitalizeString(query))
            .withHeadlinePart2(HEADLINE_PART_2)
            .withDescription(capitalizeString(query) + DESCRIPTION_ADDITION + "{param1:less money} !")
            .withPath1(PATH_1)
            .withPath2(PATH_2)
            .withFinalUrl(data[i][10])
            .build();
          } else {
            // Fallback case when the query is too long.
            adGroup.newAd()
            .expandedTextAdBuilder()
            .withHeadlinePart1(FALLBACK_HEADLINE_PART_1)
            .withHeadlinePart2(HEADLINE_PART_2)
            .withDescription(capitalizeString(query) + DESCRIPTION_ADDITION + "{param1:less money} !")
            .withPath1(PATH_1)
            .withPath2(PATH_2)
            .withFinalUrl(data[i][10])
            .build();
          }
        }
      }
    }
  }
}

function capitalizeString(string) {
  return string.replace(/\b\w/g, function(l){ return l.toUpperCase(); });
}

Der Code wurde erfolgreich in deine Zwischenablage kopiert.

Beliebte AdWords Scripts

Martin Röttgerding

“Automation can take your PPC efforts to the next level – if you’re doing it right.”

Martin Röttgerding, Head of SEA – Bloofusion Germany

Jetzt Demo anfordern

Erfahren Sie, was die AdEngine für Sie leisten kann