Search code examples
google-apps-scriptgoogle-analytics-api

Delete Google Analytics filter with Google App Scripts (delete not a function error)


I'm want to delete Google Analytics filters at view level using Google App Script and Google Analytics management API.

I'm trying to run the following function:

function delete_filter() {

var delete = Analytics.Management.ProfileFilterLinks.delete('213755:84538578', '123456','12345678','UA-12345678-1');

}

but I have the following error:

TypeError: Analytics.Management.ProfileFilterLinks.delete is not a function

Does it means that the delete function is not available with Google App Script API?


Solution

  • How about this modification? At the official document, the "Profile Filter Links: delete" method is used. But at Advanced Google services, it seems that remove is used. I think that the reason of your error message is due to this. So please modify as follows and testing it again.

    From:

    var delete = Analytics.Management.ProfileFilterLinks.delete('213755:84538578', '123456','12345678','UA-12345678-1');
    

    To:

    var delete = Analytics.Management.ProfileFilterLinks.remove(accountId, webPropertyId, profileId, linkId);
    

    Note:

    • In this case, the returned value is void. Please be careful this.
    • Please confirm whether the values of accountId, webPropertyId, profileId, linkId are correct.

    Reference: