marketing Engagement Createmutation
Requires write
access scope.
Creates a new marketing engagement for a marketing activity or a marketing channel.
Arguments
Anchor to channelHandlechannelHandleThe unique string identifier of the channel to which the engagement metrics are being provided. This should be set when and only when providing channel-level engagements. This should be nil when providing activity-level engagements. For the correct handle for your channel, contact your partner manager.
Anchor to marketingActivityIdmarketingActivityIdThe identifier of the marketing activity for which the engagement metrics are being provided. This or the remoteId should be set when and only when providing activity-level engagements. This should be nil when providing channel-level engagements.
The marketing engagement's attributes.
Anchor to remoteIdremoteIdThe ID of an activity that's hosted outside of Shopify. This or the marketingActivityId should be set when and only when providing activity-level engagements. This should be nil when providing channel-level engagements.
MarketingEngagementCreatePayload returns
The marketing engagement that was created. This represents customer activity taken on a marketing activity or a marketing channel.
The list of errors that occurred from executing the mutation.
Code examples for MUTATION: marketingEngagementCreate
Query Reference for MUTATION: marketingEngagementCreate
"mutation marketingEngagementCreate($marketingEngagement: MarketingEngagementInput!) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement) {\n marketingEngagement {\n # MarketingEngagement fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: marketingEngagementCreate
"{\n \"channelHandle\": \"<your-channelHandle>\",\n \"marketingActivityId\": \"gid://shopify/<objectName>/10079785100\",\n \"marketingEngagement\": {\n \"adSpend\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"clicksCount\": 1,\n \"commentsCount\": 1,\n \"complaintsCount\": 1,\n \"failsCount\": 1,\n \"favoritesCount\": 1,\n \"firstTimeCustomers\": \"29.99\",\n \"impressionsCount\": 1,\n \"isCumulative\": true,\n \"occurredOn\": \"2019-07-16\",\n \"orders\": \"29.99\",\n \"returningCustomers\": \"29.99\",\n \"sales\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"sendsCount\": 1,\n \"sessionsCount\": 1,\n \"sharesCount\": 1,\n \"uniqueClicksCount\": 1,\n \"uniqueViewsCount\": 1,\n \"unsubscribesCount\": 1,\n \"utcOffset\": \"-07:00\",\n \"viewsCount\": 1\n },\n \"remoteId\": \"<your-remoteId>\"\n}"
Schema Reference for MUTATION: marketingEngagementCreate
"input MarketingEngagementInput {\n adSpend: MoneyInput\n clicksCount: Int\n commentsCount: Int\n complaintsCount: Int\n failsCount: Int\n favoritesCount: Int\n firstTimeCustomers: Decimal\n impressionsCount: Int\n isCumulative: Boolean!\n occurredOn: Date!\n orders: Decimal\n returningCustomers: Decimal\n sales: MoneyInput\n sendsCount: Int\n sessionsCount: Int\n sharesCount: Int\n uniqueClicksCount: Int\n uniqueViewsCount: Int\n unsubscribesCount: Int\n utcOffset: UtcOffset!\n viewsCount: Int\n}\n\ninput MoneyInput {\n amount: Decimal!\n currencyCode: CurrencyCode!\n}\n"
Display Examples for MUTATION: marketingEngagementCreate
[ { "example": { "type_name": "marketingengagementcreate", "title": "Create activity-level engagement for a marketing activity ID", "query_string": "mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n}", "response": { "data": { "marketingEngagementCreate": { "marketingEngagement": { "occurredOn": "2018-06-29", "utcOffset": "-07:00", "isCumulative": false, "adSpend": { "amount": "19.9", "currencyCode": "CAD" }, "clicksCount": 40, "impressionsCount": 100, "commentsCount": 1, "favoritesCount": 0, "unsubscribesCount": 1, "complaintsCount": 1, "failsCount": 1, "sendsCount": 1, "uniqueViewsCount": 1, "uniqueClicksCount": 1, "sharesCount": 5, "viewsCount": 10, "sessionsCount": 40, "sales": { "amount": "304.5", "currencyCode": "CAD" }, "orders": "8.0", "firstTimeCustomers": "5.0", "returningCustomers": "3.0", "marketingActivity": { "id": "gid://shopify/MarketingActivity/794355127" }, "channelHandle": null }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2024-01", "location": "/components/merchant_marketing/test/unit/graph_api/admin/mutations/marketing_engagement_create_test.rb", "maximum_api_version": null, "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) { marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) { marketingEngagement { occurredOn utcOffset isCumulative adSpend { amount currencyCode } clicksCount impressionsCount commentsCount favoritesCount unsubscribesCount complaintsCount failsCount sendsCount uniqueViewsCount uniqueClicksCount sharesCount viewsCount sessionsCount sales { amount currencyCode } orders firstTimeCustomers returningCustomers marketingActivity { id } channelHandle } userErrors { field message } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] }, { "example": { "type_name": "marketingengagementcreate", "title": "Create activity-level engagement with a remote ID", "query_string": "mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n}", "response": { "data": { "marketingEngagementCreate": { "marketingEngagement": { "occurredOn": "2018-06-29", "utcOffset": "-07:00", "isCumulative": false, "adSpend": { "amount": "19.9", "currencyCode": "CAD" }, "clicksCount": 40, "impressionsCount": 100, "commentsCount": 1, "favoritesCount": 0, "unsubscribesCount": 1, "complaintsCount": 1, "failsCount": 1, "sendsCount": 1, "uniqueViewsCount": 1, "uniqueClicksCount": 1, "sharesCount": 5, "viewsCount": 10, "sessionsCount": 40, "sales": { "amount": "304.5", "currencyCode": "CAD" }, "orders": "8.0", "firstTimeCustomers": "5.0", "returningCustomers": "3.0", "marketingActivity": { "id": "gid://shopify/MarketingActivity/794355127" }, "channelHandle": null }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2024-01", "location": "/components/merchant_marketing/test/unit/graph_api/admin/mutations/marketing_engagement_create_test.rb", "maximum_api_version": null, "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) { marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) { marketingEngagement { occurredOn utcOffset isCumulative adSpend { amount currencyCode } clicksCount impressionsCount commentsCount favoritesCount unsubscribesCount complaintsCount failsCount sendsCount uniqueViewsCount uniqueClicksCount sharesCount viewsCount sessionsCount sales { amount currencyCode } orders firstTimeCustomers returningCustomers marketingActivity { id } channelHandle } userErrors { field message } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] }, { "example": { "type_name": "marketingengagementcreate", "title": "Create channel-level engagement for a channel handle", "query_string": "mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n}", "response": { "data": { "marketingEngagementCreate": { "marketingEngagement": { "occurredOn": "2018-06-29", "utcOffset": "-07:00", "isCumulative": false, "adSpend": { "amount": "19.9", "currencyCode": "CAD" }, "clicksCount": 40, "impressionsCount": 100, "commentsCount": 1, "favoritesCount": 0, "unsubscribesCount": 1, "complaintsCount": 1, "failsCount": 1, "sendsCount": 1, "uniqueViewsCount": 1, "uniqueClicksCount": 1, "sharesCount": 5, "viewsCount": 10, "sessionsCount": 40, "sales": { "amount": "304.5", "currencyCode": "CAD" }, "orders": "8.0", "firstTimeCustomers": "5.0", "returningCustomers": "3.0", "marketingActivity": null, "channelHandle": "my-channel-handle" }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2024-01", "location": "/components/merchant_marketing/test/unit/graph_api/admin/mutations/marketing_engagement_create_test.rb", "maximum_api_version": null, "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) { marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) { marketingEngagement { occurredOn utcOffset isCumulative adSpend { amount currencyCode } clicksCount impressionsCount commentsCount favoritesCount unsubscribesCount complaintsCount failsCount sendsCount uniqueViewsCount uniqueClicksCount sharesCount viewsCount sessionsCount sales { amount currencyCode } orders firstTimeCustomers returningCustomers marketingActivity { id } channelHandle } userErrors { field message } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID, $channelHandle: String, $remoteId: String) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId, channelHandle: $channelHandle, remoteId: $remoteId) {\n marketingEngagement {\n occurredOn\n utcOffset\n isCumulative\n adSpend {\n amount\n currencyCode\n }\n clicksCount\n impressionsCount\n commentsCount\n favoritesCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n sharesCount\n viewsCount\n sessionsCount\n sales {\n amount\n currencyCode\n }\n orders\n firstTimeCustomers\n returningCustomers\n marketingActivity {\n id\n }\n channelHandle\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] }, { "example": { "type_name": "marketingengagementcreate", "title": "Create engagement for the marketing activity using the marketing activity ID", "query_string": "mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID!) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId) {\n marketingEngagement {\n occurredOn\n clicksCount\n commentsCount\n favoritesCount\n impressionsCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n isCumulative\n fetchedAt\n utcOffset\n adSpend {\n amount\n currencyCode\n }\n marketingActivity {\n id\n }\n }\n userErrors {\n field\n message\n }\n }\n}", "response": { "data": { "marketingEngagementCreate": { "marketingEngagement": { "occurredOn": "2018-06-29", "clicksCount": 40, "commentsCount": 1, "favoritesCount": 0, "impressionsCount": 100, "unsubscribesCount": 1, "complaintsCount": 1, "failsCount": 1, "sendsCount": 1, "uniqueViewsCount": 1, "uniqueClicksCount": 1, "isCumulative": true, "fetchedAt": "2018-06-28T18:32:23Z", "utcOffset": "-07:00", "adSpend": { "amount": "19.9", "currencyCode": "CAD" }, "marketingActivity": { "id": "gid://shopify/MarketingActivity/794355127" } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2024-01", "location": "/components/merchant_marketing/test/unit/graph_api/admin/mutations/marketing_engagement_create_test.rb", "maximum_api_version": null, "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID!) { marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId) { marketingEngagement { occurredOn clicksCount commentsCount favoritesCount impressionsCount unsubscribesCount complaintsCount failsCount sendsCount uniqueViewsCount uniqueClicksCount isCumulative fetchedAt utcOffset adSpend { amount currencyCode } marketingActivity { id } } userErrors { field message } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID!) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId) {\n marketingEngagement {\n occurredOn\n clicksCount\n commentsCount\n favoritesCount\n impressionsCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n isCumulative\n fetchedAt\n utcOffset\n adSpend {\n amount\n currencyCode\n }\n marketingActivity {\n id\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID!) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId) {\n marketingEngagement {\n occurredOn\n clicksCount\n commentsCount\n favoritesCount\n impressionsCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n isCumulative\n fetchedAt\n utcOffset\n adSpend {\n amount\n currencyCode\n }\n marketingActivity {\n id\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID!) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId) {\n marketingEngagement {\n occurredOn\n clicksCount\n commentsCount\n favoritesCount\n impressionsCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n isCumulative\n fetchedAt\n utcOffset\n adSpend {\n amount\n currencyCode\n }\n marketingActivity {\n id\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation M($marketingEngagement: MarketingEngagementInput!, $marketingActivityId: ID!) {\n marketingEngagementCreate(marketingEngagement: $marketingEngagement, marketingActivityId: $marketingActivityId) {\n marketingEngagement {\n occurredOn\n clicksCount\n commentsCount\n favoritesCount\n impressionsCount\n unsubscribesCount\n complaintsCount\n failsCount\n sendsCount\n uniqueViewsCount\n uniqueClicksCount\n isCumulative\n fetchedAt\n utcOffset\n adSpend {\n amount\n currencyCode\n }\n marketingActivity {\n id\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] } ]