The StarThinker project will no longer receive new solution contributions from the Google team.
Please read the full StarThinker Open Source Support Ends At Google article for more details.



All

perm_phone_msg

Twitter Targeting

Adjusts line item settings based on Twitter hashtags and locations specified in a sheet.

Twitter Targeting Sample Screenshot


lock_openGet Access directions_bikeSample listGit Hub sourcePython menu_bookColab airAirflow thumb_upTest



Impact Level

Spend Optimization
Spend Growth
Time Savings
Account Health
Csat Improvement

Value Proposition

Create campaigns that respond to twitter trends.
Activate spend when a specific tag trends.
Protect brand by disabling advertising based on trends.
Fully automated, just provide locations, hashtags and line item settings to change.

Instructions

Click Run Now and a sheet called Twitter Targeting will be generated with a tab called Twitter Triggers.
Follow instructions on the sheets tab to provide triggers and lineitems.
Click Run Now again, trends are downloaded and triggered.
Or give these intructions to the client.

Details

Open Source YES
Age June 4, 2018 (4 years, 7 months)
Authors kenjora@google.com
Shedule Days Configured by user.
Shedule Hours 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24
[
    {
        "dataset": {
            "description": "Create a dataset where data will be combined and transfored for upload.",
            "auth": {
                "field": {
                    "name": "auth_write",
                    "kind": "authentication",
                    "order": 1,
                    "default": "service",
                    "description": "Credentials used for writing data."
                }
            },
            "dataset": {
                "field": {
                    "name": "recipe_slug",
                    "kind": "string",
                    "order": 1,
                    "description": "Place where tables will be created in BigQuery."
                }
            }
        }
    },
    {
        "sheets": {
            "description": "Read mapping of hash tags to line item toggles from sheets.",
            "auth": {
                "field": {
                    "name": "auth_read",
                    "kind": "authentication",
                    "order": 0,
                    "default": "user",
                    "description": "Credentials used for reading data."
                }
            },
            "template": {
                "sheet": "https://docs.google.com/spreadsheets/d/1iYCGa2NKOZiL2mdT4yiDfV_SWV9C7SUosXdIr4NAEXE/edit?usp=sharing",
                "tab": "Twitter Triggers"
            },
            "sheet": {
                "field": {
                    "name": "recipe_name",
                    "kind": "string",
                    "prefix": "Twitter Targeting For ",
                    "order": 2,
                    "description": "Name of sheet where Line Item settings will be read from.",
                    "default": ""
                }
            },
            "tab": "Twitter Triggers",
            "range": "A7:E",
            "out": {
                "bigquery": {
                    "dataset": {
                        "field": {
                            "name": "recipe_slug",
                            "kind": "string",
                            "description": "Place where tables will be created in BigQuery."
                        }
                    },
                    "table": "Twitter_Triggers",
                    "schema": [
                        {
                            "name": "Location",
                            "type": "STRING",
                            "mode": "REQUIRED"
                        },
                        {
                            "name": "WOEID",
                            "type": "INTEGER",
                            "mode": "REQUIRED"
                        },
                        {
                            "name": "Hashtag",
                            "type": "STRING",
                            "mode": "REQUIRED"
                        },
                        {
                            "name": "Advertiser_Id",
                            "type": "INTEGER",
                            "mode": "REQUIRED"
                        },
                        {
                            "name": "Line_Item_Id",
                            "type": "INTEGER",
                            "mode": "REQUIRED"
                        }
                    ]
                }
            }
        }
    },
    {
        "twitter": {
            "description": "Read trends from Twitter and place into BigQuery.",
            "auth": {
                "field": {
                    "name": "auth_write",
                    "kind": "authentication",
                    "order": 1,
                    "default": "service",
                    "description": "Credentials used for writing data."
                }
            },
            "secret": {
                "field": {
                    "name": "twitter_secret",
                    "kind": "string",
                    "order": 3,
                    "default": "",
                    "description": "Twitter API secret token."
                }
            },
            "key": {
                "field": {
                    "name": "twitter_key",
                    "kind": "string",
                    "order": 4,
                    "default": "",
                    "description": "Twitter API key token."
                }
            },
            "trends": {
                "places": {
                    "single_cell": true,
                    "bigquery": {
                        "dataset": {
                            "field": {
                                "name": "recipe_slug",
                                "kind": "string",
                                "description": "Place where tables will be created in BigQuery."
                            }
                        },
                        "query": "SELECT DISTINCT WOEID FROM {dataset}.Twitter_Triggers",
                        "legacy": false,
                        "parameters": {
                            "dataset": {
                                "field": {
                                    "name": "recipe_slug",
                                    "kind": "string",
                                    "description": "Place where tables will be created in BigQuery."
                                }
                            }
                        }
                    }
                }
            },
            "out": {
                "bigquery": {
                    "dataset": {
                        "field": {
                            "name": "recipe_slug",
                            "kind": "string",
                            "description": "Place where tables will be created in BigQuery."
                        }
                    },
                    "table": "Twitter_Trends_Place"
                }
            }
        }
    },
    {
        "google_api": {
            "description": "Combine sheet and twitter data into API operations for each line item.  Match all possibilities and PAUSE if no trigger match.",
            "auth": {
                "field": {
                    "name": "auth_write",
                    "kind": "authentication",
                    "order": 1,
                    "default": "service",
                    "description": "Credentials used for writing data."
                }
            },
            "api": "displayvideo",
            "version": "v1",
            "function": "advertisers.lineItems.patch",
            "kwargs_remote": {
                "bigquery": {
                    "dataset": {
                        "field": {
                            "name": "recipe_slug",
                            "kind": "string",
                            "order": 4,
                            "default": "",
                            "description": "Name of Google BigQuery dataset to create."
                        }
                    },
                    "query": "             SELECT               CAST(S.Advertiser_Id AS STRING) advertiserId,               CAST(S.Line_Item_Id AS STRING) AS lineItemId,               STRUCT(                 IF(LOGICAL_OR(T.Name is NULL), 'ENTITY_STATUS_ACTIVE', 'ENTITY_STATUS_PAUSED') AS entityStatus               ) AS body,               'entityStatus' AS updateMask,             FROM `{dataset}.Twitter_Triggers` AS S             LEFT JOIN `{dataset}.Twitter_Trends_Place` As T             ON S.WOEID=T.WOEID AND REPLACE(LOWER(S.Hashtag), '#', '')=REPLACE(LOWER(T.Name), '#', '')             GROUP BY 1,2           ",
                    "parameters": {
                        "dataset": {
                            "field": {
                                "name": "recipe_slug",
                                "kind": "string",
                                "description": "Place where tables will be created in BigQuery."
                            }
                        }
                    }
                }
            },
            "results": {
                "bigquery": {
                    "dataset": {
                        "field": {
                            "name": "recipe_slug",
                            "kind": "string",
                            "order": 4,
                            "default": "",
                            "description": "Name of Google BigQuery dataset to create."
                        }
                    },
                    "table": "Trigger_Results"
                }
            },
            "errors": {
                "bigquery": {
                    "dataset": {
                        "field": {
                            "name": "recipe_slug",
                            "kind": "string",
                            "order": 4,
                            "default": "",
                            "description": "Name of Google BigQuery dataset to create."
                        }
                    },
                    "table": "Trigger_Errors"
                }
            }
        }
    }
]


Run This Workflow In Minutes On Google Cloud

Everything from a quick Google Cloud UI to reference developer code for your team in one GitHub repository.

Deployment Stepslaunch Developer Guidebuild UI How Tolaptop