![]() |
VOOZH | about |
The CData Cmdlets for Google Campaign Manager 360 are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Google Campaign Manager 360.
The Cmdlets are not only a PowerShell interface to Google Campaign Manager 360, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Google Campaign Manager 360 data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Google Campaign Manager 360. To access Google Campaign Manager 360 data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Google Campaign Manager 360.
Once you have acquired the necessary connection properties, accessing Google Campaign Manager 360 data in PowerShell can be enabled in three steps.
Google Campaign Manager uses the OAuth authentication standard. The data provider facilitates OAuth in various ways as described below. The following OAuth flow requires the authenticating user to interact with DoubleClick Campaign Manager, using the browser. You can also use a service account to authenticate.
For authentication guides, see the Getting Started section of the data provider help documentation.
Install the module:
Install-Module GoogleCMCmdlets
Connect:
$googlecm = Connect-GoogleCM -UserProfileID "$UserProfileID" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$device = "Mobile devices with full browsers" $campaignperformance = Select-GoogleCM -Connection $googlecm -Table "CampaignPerformance" -Where "Device = `'$Device`'" $campaignperformance
You can also use the Invoke-GoogleCM cmdlet to execute SQL commands:
$campaignperformance = Invoke-GoogleCM -Connection $googlecm -Query 'SELECT * FROM CampaignPerformance WHERE Device = @Device' -Params @{'@Device'='Mobile devices with full browsers'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Google Campaign Manager 360\lib\System.Data.CData.GoogleCM.dll")
Connect to Google Campaign Manager 360:
$conn= New-Object System.Data.CData.GoogleCM.GoogleCMConnection("UserProfileID=MyUserProfileID;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the GoogleCMDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Clicks, Device from CampaignPerformance"
$da= New-Object System.Data.CData.GoogleCM.GoogleCMDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.clicks $_.device
}
Update-GoogleCM -Connection $GoogleCM -Columns @('Clicks','Device') -Values @('MyClicks', 'MyDevice') -Table CampaignPerformance -Id "MyId"
$cmd = New-Object System.Data.CData.GoogleCM.GoogleCMCommand("UPDATE CampaignPerformance SET Device='Mobile devices with full browsers' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.GoogleCM.GoogleCMParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-GoogleCM -Connection $GoogleCM -Table CampaignPerformance -Columns @("Clicks", "Device") -Values @("MyClicks", "MyDevice")
$cmd = New-Object System.Data.CData.GoogleCM.GoogleCMCommand("INSERT INTO CampaignPerformance (Device) VALUES (@myDevice)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.GoogleCM.GoogleCMParameter("@myDevice","Mobile devices with full browsers")))
$cmd.ExecuteNonQuery()
Remove-GoogleCM -Connection $GoogleCM -Table "CampaignPerformance" -Id "MyId"
$cmd = New-Object System.Data.CData.GoogleCM.GoogleCMCommand("DELETE FROM CampaignPerformance WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.GoogleCM.GoogleCMParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Google Campaign Manager 360 Data Provider to get started:
Download NowLearn more:
👁 Google Campaign Manager 360 IconAn easy-to-use database-like interface for .NET applications access to live Google Campaign Manager 360 data (Ads, Accounts, Creatives, Orders, and more).