Autonomy is increasingly demanded to industrial manipulators. Robots have to be capable to regulate their behavior to different operational conditions, adapting to the specific task to be executed without requiring high time/resource-consuming human intervention. Achieving an automated tuning of the control parameters of a manipulator is still a challenging task, which involves modeling/identification of the robot dynamics. This usually results in an onerous procedure, both in terms of experimental and data-processing time. This paper addresses the problem of automated tuning of the manipulator controller for trajectory tracking, optimizing control parameters based on the specific trajectory to be executed. A Bayesian optimization algorithm is proposed to tune both the low-level controller parameters (i.e., the equivalent link-masses of the feedback linearizator and the feedforward controller) and the high-level controller parameters (i.e., the joint PID gains). The algorithm adapts the control parameters through a data-driven procedure, optimizing a user-defined trajectory-tracking cost. Safety constraints ensuring, e.g., closed-loop stability and bounds on the maximum joint position error are also included. The performance of proposed approach is demonstrated on a torquecontrolled 7-degree-of-freedom FRANKA Emika robot manipulator. The 25 robot control parameters (i.e., 4 link-mass parameters and 21 PID gains) are tuned in less than 130 iterations, and comparable results with respect to the FRANKA Emika embedded position controller are achieved. In addition, the generalization capabilities of the proposed approach are shown exploiting the proper reference trajectory for the tuning of the control parameters.