Hi there, I have 2 sources (google leads and php) ...
# support
a
Hi there, I have 2 sources (google leads and php) connected to a customer.io destination. I've created a transformation that should apply to the google leads but it's also applying to the php source which results in a ton of errors. Is there a way to only have the transformation apply to the google leads source?
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
Hi Jannie, a transformation is applied to a destination hence it is being applied to events coming from both sources. The best way to overcome this would be to first filter the events coming from the google leads in the user transformation and then apply the transformation code. The event generally contains properties that help you distinguish between sources such as context.app.name, context.app.version, context.library.name or context.library.version. However, a cleaner way to do this would be to use the metadata, which contains the sourceId and this sourceId be used as a filter.
s
Copy code
export function transformEvent(event, metadata) {
  const met = metadata(event);
  if (
    met &&
    met.sourceId === <Google_leads_sourceId>) {
       // Do something
  }
  ...  
  return event;
}
a
That makes perfect sense, thanks for your help.
m
:)