Access to UTM campaign fields via API?

Highlighted
Excursionist
78 0 8

Can someone tell me if I'm just missing somewhere we can retrieve the UTM Campaign, UTM Name, and UTM Source fields that you can download in reports via the API (GraphQL or REST)? I can't seem to find anything about it, but it seems like they should be available somewhere.

0 Likes
Shopify Staff
Shopify Staff
1360 54 201

Hey @MrPunkin.

 

You can access this information on a CustomerVisit via the Admin GraphQL API. This can be accessed through Order.CustomerJourney.Moment(CustomerVisit). A query for that would look like this:

 

query {
  orders(first:200) {
    edges {
      node {
        customerJourney {
          moments {
            ...on CustomerVisit {
              utmParameters {
                source
                campaign
                content
                medium
                term
              }
            }
          }
        }
      }
    }
  }
}

The above makes use of inline fragments, which you can learn more about here if that's unfamiliar to you.

0 Likes
Excursionist
78 0 8

Alex,

 

Thanks for this info. I'll spend some time digging into this today.

0 Likes
Shopify Staff
Shopify Staff
1360 54 201

To get that data on a specific order, you can query that order directly:

 

{
  order(id: "gid://shopify/Order/5642150741") {
    id
    customerJourney {
      moments {
        ... on CustomerVisit {
          utmParameters {
            source
            campaign
            content
            medium
            term
          }
        }
      }
    }
  }
}

Let me know though if I'm misunderstanding your question.

 

Edit

 

Looks like you edited your post, I'll put this up regardless.

0 Likes
Excursionist
78 0 8

I did, sorry. I didn't notice that all of this was nested under the orders data at first. This should be what I need, but I'll let you know if it isn't for some reason.

0 Likes