// Get the ActivityGroupService.
ActivityGroupServiceInterface activityGroupService =
dfpServices.get(session, ActivityGroupServiceInterface.class);
// Create a short-term activity group.
ActivityGroup shortTermActivityGroup = new ActivityGroup();
shortTermActivityGroup.setName(
"Short-term activity group #" + new Random().nextInt(Integer.MAX_VALUE));
shortTermActivityGroup.setCompanyIds(new long[] {advertiserCompanyId});
shortTermActivityGroup.setClicksLookback(1);
shortTermActivityGroup.setImpressionsLookback(1);
// Create a long-term activity group.
ActivityGroup longTermActivityGroup = new ActivityGroup();
longTermActivityGroup.setName(
"Long-term activity group #" + new Random().nextInt(Integer.MAX_VALUE));
longTermActivityGroup.setCompanyIds(new long[] {advertiserCompanyId});
longTermActivityGroup.setClicksLookback(30);
longTermActivityGroup.setImpressionsLookback(30);
// Create the activity groups on the server.
ActivityGroup[] activityGroups = activityGroupService.createActivityGroups(
new ActivityGroup[] {shortTermActivityGroup, longTermActivityGroup});