Edits history of script submission #11222 for ' Create conversion tag (pinterest)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Pinterest = {
      token: string;
    };
    /**
     * Create conversion tag
     * Create a conversion tag, also known as Pinterest tag, with the option to enable enhanced match.
    The Pinterest Tag tracks actions people take on the ad account’ s website after they view the ad account's ad on Pinterest. The advertiser needs to customize this tag to track conversions.
    For more information, see:
    Set up the Pinterest tag
    Pinterest Tag
    Enhanced match
     */
    export async function main(
      auth: Pinterest,
      ad_account_id: string,
      body: {
        aem_enabled?: false | true;
        md_frequency?: number;
        aem_fnln_enabled?: false | true;
        aem_ph_enabled?: false | true;
        aem_ge_enabled?: false | true;
        aem_db_enabled?: false | true;
        aem_loc_enabled?: false | true;
      } & { name: string },
    ) {
      const url = new URL(
        `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/conversion_tags`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 536 days ago