Split Google Ads copy into titles, long titles and descriptions.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -138,6 +138,14 @@ function enumName(v?: string): string {
|
||||
return (v || '').replace(/^[A-Z0-9]+_/, '') || str(v);
|
||||
}
|
||||
|
||||
/** Do not strip LONG_HEADLINE → HEADLINE (enumName would). */
|
||||
function assetFieldType(v?: string): string {
|
||||
return str(v)
|
||||
.toUpperCase()
|
||||
.replace(/^ASSET_FIELD_TYPE_/, '')
|
||||
.replace(/^ASSETFIELDTYPE_/, '');
|
||||
}
|
||||
|
||||
function uniq(arr: string[]): string[] {
|
||||
return [...new Set(arr.filter(Boolean))];
|
||||
}
|
||||
@@ -600,7 +608,7 @@ WHERE ad_group_ad.status != 'REMOVED'
|
||||
const adId = str(row.adGroupAd?.ad?.id);
|
||||
if (!adId) continue;
|
||||
const list = assetsByAdId.get(adId) || [];
|
||||
const ft = enumName(row.adGroupAdAssetView?.fieldType).toUpperCase();
|
||||
const ft = assetFieldType(row.adGroupAdAssetView?.fieldType);
|
||||
const img = str(row.asset?.imageAsset?.fullSize?.url);
|
||||
const w = n(row.asset?.imageAsset?.fullSize?.widthPixels) || undefined;
|
||||
const h = n(row.asset?.imageAsset?.fullSize?.heightPixels) || undefined;
|
||||
@@ -698,7 +706,7 @@ WHERE ad_group_ad.status != 'REMOVED'
|
||||
};
|
||||
agMap.set(agid, entry);
|
||||
}
|
||||
const ft = enumName(row.assetGroupAsset?.fieldType).toUpperCase();
|
||||
const ft = assetFieldType(row.assetGroupAsset?.fieldType);
|
||||
const text = str(row.asset?.textAsset?.text);
|
||||
const img = str(row.asset?.imageAsset?.fullSize?.url);
|
||||
const imgW = n(row.asset?.imageAsset?.fullSize?.widthPixels) || undefined;
|
||||
@@ -804,12 +812,12 @@ WHERE ad_group_ad.status != 'REMOVED'
|
||||
}),
|
||||
thumbnailUrl: preview,
|
||||
imageUrl: preview,
|
||||
headline: [...headlines, ...longHeadlines].join('\n'),
|
||||
headline: headlines.join('\n'),
|
||||
primaryText: descriptions.join('\n'),
|
||||
headlines,
|
||||
bodies: descriptions,
|
||||
bodies: [],
|
||||
longHeadlines,
|
||||
descriptions: [],
|
||||
descriptions,
|
||||
sitelinks,
|
||||
callouts,
|
||||
snippets,
|
||||
@@ -914,12 +922,12 @@ WHERE ad_group_ad.status != 'REMOVED'
|
||||
}),
|
||||
thumbnailUrl: preview,
|
||||
imageUrl: preview,
|
||||
headline: [...headlines, ...longHeadlines].join('\n'),
|
||||
headline: headlines.join('\n'),
|
||||
primaryText: descriptions.join('\n'),
|
||||
headlines,
|
||||
bodies: descriptions,
|
||||
bodies: [],
|
||||
longHeadlines,
|
||||
descriptions: [],
|
||||
descriptions,
|
||||
assets,
|
||||
linkUrl: (ad?.finalUrls || []).map(str).filter(Boolean)[0],
|
||||
cta: str(rda?.callToActionText) || undefined,
|
||||
@@ -928,7 +936,7 @@ WHERE ad_group_ad.status != 'REMOVED'
|
||||
youtubeId: firstYt,
|
||||
});
|
||||
if (paths.length) {
|
||||
cards[cards.length - 1].bodies = [
|
||||
cards[cards.length - 1].descriptions = [
|
||||
...descriptions,
|
||||
`Path: /${paths.join('/')}`,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user