forked from kritzware/google-ads-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
37 lines (30 loc) · 815 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"fmt"
"github.com/hurbcom/google-ads-go/ads"
"github.com/hurbcom/google-ads-go/services"
"log"
)
func main() {
// Create a client from credentials file
client, err := ads.NewClientFromStorage("credentials.json")
if err != nil {
panic(err)
}
// Load the "GoogleAds" service
googleAdsService := services.NewGoogleAdsServiceClient(client.Conn())
// Create a search request
request := services.SearchGoogleAdsRequest{
CustomerId: "12345678",
Query: "SELECT segments.date, click_view.gclid FROM click_view WHERE segments.date = '2021-07-23'",
}
// Get the results
response, err := googleAdsService.Search(client.Context(), &request)
if err != nil {
log.Fatal(err)
}
// Printing results
for _, row := range response.Results {
fmt.Println(row.ClickView)
}
}