Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a custom segment via the SDK? #482

Open
roundrobin opened this issue Nov 9, 2023 · 1 comment
Open

How to create a custom segment via the SDK? #482

roundrobin opened this issue Nov 9, 2023 · 1 comment

Comments

@roundrobin
Copy link

Hi team,

I tried creating a custom segment via the SDK; but couldn't find a way.
Can you help me out here? and point me in the right direction?

I was trying this approach without any success:

const clientID = process.env.CLIENT_ID;
const clientSecret = process.env.CLIENT_SECRET;
const refreshToken = process.env.REFRESH_TOKEN;
const customerID = process.env.CUSTOMER_ID;

const developerToken = process.env.DEVELOPER_TOKEN;

const { GoogleAdsApi } = require("google-ads-api");

const client = new GoogleAdsApi({
  client_id: clientID,
  client_secret: clientSecret,
  developer_token: developerToken
});

async function createCustomSegment() {
  const customer = client.Customer({
    customer_id: customerID,
    refresh_token: refreshToken
  });

  const segment = {
    name: "Custom Segment Nils",
    type: "INTEREST",
    status: "ENABLED",
    description: "A custom segment based on interests",
    criteria: ["ios developer jobs"] // Replace with your interests
  };

  console.log("customer.segments", customer);

  const response = await customer.segments.create(segment);
  console.log(`Created segment with ID ${response.id}`);
}

createCustomSegment().catch(console.error);

@roundrobin
Copy link
Author

Bildschirm­foto 2023-11-09 um 12 27 15 I'm referring to this area

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant