Access to UTM campaign fields via API?

MrPunkin
Explorer
84 0 28

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
Alex
Shopify Staff
Shopify Staff
1555 81 293

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.

MrPunkin
Explorer
84 0 28

Alex,

 

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

0 Likes
Alex
Shopify Staff
Shopify Staff
1555 81 293

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
MrPunkin
Explorer
84 0 28

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
謝紹壯
New Member
4 0 0

excuse me:

How to get UTM parameters through rest admin API?

0 Likes
謝紹壯
New Member
4 0 0

I have been searching for rest admin API document for a long time, but I haven't found the appropriate interface to get the UTM parameters associated with the order.

How to get UTM parameters through rest admin API?

0 Likes
MrPunkin
Explorer
84 0 28

Unfortunately I believe this is only available via the GraphQL API, and does not exist within the REST API. I had to implement the GraphQL API for my needs to track the UTM variables from the CustomerJourney object.

0 Likes
謝紹壯
New Member
4 0 0
There is a question.
Since the UTM parameter can be obtained in graphql API, indicating that the order is associated with this parameter, why not open it in the rest API?
0 Likes