Extract and flatten 'deeplinkAdCard' JSON from a Facebook Ad Library page
Source:R/get_media.R
get_deeplink.RdThis function programmatically retrieves the embedded JSON object labeled deeplinkAdCard
from the source code of a Facebook Ad Library ad page.
Value
A tibble with one row, containing flattened columns extracted from the deeplink JSON object.
Columns depend on the structure of the JSON and may include fields like fevInfo_*,
fevInfo_free_form_additional_info_*, fevInfo_learn_more_content_*, and snapshot-related columns.
Details
The function performs the following steps internally:
Fetches the ad page HTML from Facebook's Ad Library for the specified
ad_id.Locates the
<script>tag containing thedeeplinkAdCardobject.Uses a recursive regular expression to extract the full JSON object following
deeplinkAdCard.Parses the JSON string into a nested R list.
Flattens the JSON into a tidy tibble row, unnesting nested sub-objects such as
fevInfo,free_form_additional_info,learn_more_content, and optionallysnapshotif present.
The output is designed for downstream analysis: each ad is represented as one row in a tibble,
with nested JSON fields expanded into their own columns via tidyr::unnest_wider().
This function complements get_ad_snapshots(), which extracts the snapshot JSON.
Use get_deeplink() when additional metadata embedded under deeplinkAdCard is required.
See also
get_ad_snapshots() for extracting snapshot JSON; detectmysnap() for raw JSON detection.