14.4 Create and configure a Google Cloud Function
Create and configure a Google Cloud Function
Last updated
Create and configure a Google Cloud Function
Last updated
Go to https://console.cloud.google.com/. Go to Cloud Functions.
You'll then see this. Click CREATE FUNCTION.
You'll then see this.
Make the following choices:
Function name: --demoProfileLdap---event-forwarding
Region: select any region
Trigger Type: select HTTP
Authentication: select Allow unauthenticated invocations
You should now have this. Click SAVE.
Click NEXT.
You'll then see this:
Make the following choices:
Runtime: select Node.js 16 (or more recent)
Entry point: enter helloAEP
Click ENABLE API to enable Cloud Build API. You'll then see a new window. In that new window, click ENABLE again.
You'll then see this. Click Enable.
Once Cloud Build API has been enabled, you'll see this.
Go back to your Cloud Function. In your Cloud Function Inline Editor, make sure you have the following code there:
Next, click DEPLOY.
You'll then see this. Your Cloud Function is now being created. This may take a couple of minutes.
Once your function is created and running, you'll see this. Click on your function's name to open it.
You'll then see this. Go to TRIGGER. You'll then see the Trigger URL which is what you'll use to define the endpoint in Launch Server Side.
Copy the Trigger URL, which looks like this: https://europe-west1-dazzling-pillar-273812.cloudfunctions.net/vangeluw-event-forwarding.
In the next steps, you'll configure Adobe Experience Platform Data Collection Server to stream specific information about Page Views to your Google Cloud Function. Instead of just forwarding the full payload as-is, you'll only send things like ECID, timestamp and Page Name to your Google Cloud Function.
Here's an example of a payload that you'll need to parse to filter out the above mentioned variables:
These are the fields that contain the information that needs to be parsed out:
ECID: events.xdm._experienceplatform.identification.core.ecid
timestamp: timestamp
Page Name: events.xdm.web.webPageDetails.name
Let's go to Adobe Experience Platform Data Collection Server now, to configure the data elements to make that possible.
Go to https://experience.adobe.com/#/data-collection/ and go to Event Forwarding. Search your Event Forwarding property and click it to open it.
In the left menu, go to Data Elements. Click Add Data Element.
You'll then see a new data element to configure.
Make the following selection:
As the Name, enter customerECID.
As the Extension, select Core.
As the Data Element Type, select Path.
As the Path, enter arc.event.xdm.--aepTenantId--.identification.core.ecid
. By entering this path, you'll be filtering out the field ecid from the event payload that is sent by the website or mobile app into the Adobe Edge.
In the above and below paths, a reference is made to arc. arc stands for Adobe Resource Context and arc always stands for the highest available object that is available in the Server Side context. Enrichments and transformations may be added to that arc object using Adobe Experience Platform Data Collection Server functions.
In the above and below paths, a reference is made to event. event stands for a unique event and Adobe Experience Platform Data Collection Server will always evaluate every event individually. Sometimes, you may see a reference to events in the payload sent by Web SDK Client Side, but in Adobe Experience Platform Data Collection Server, every event is evaluated individually.
You'll now have this. Click Save.
Click Add Data Element.
You'll then see a new data element to configure.
Make the following selection:
As the Name, enter eventTimestamp.
As the Extension, select Core.
As the Data Element Type, select Path.
As the Path, enter arc.event.xdm.timestamp. By entering this path, you'll be filtering out the field timestamp from the event payload that is sent by the website or mobile app into the Adobe Edge.
You'll now have this. Click Save.
Click Add Data Element.
You'll then see a new data element to configure.
Make the following selection:
As the Name, enter pageName.
As the Extension, select Core.
As the Data Element Type, select Path.
As the Path, enter arc.event.xdm.web.webPageDetails.name. By entering this path, you'll be filtering out the field name from the event payload that is sent by the website or mobile app into the Adobe Edge.
You'll now have this. Click Save.
You now have these data elements created:
In the left menu, go to Rules. In the previous exercise, you created the rule All Pages. Click that rule to open it.
You'll then this. Click the + icon under Actions to add a new action.
You'll then see this.
Make the following selection:
Select the Extension: Adobe Cloud Connector.
Select the Action Type: Make Fetch Call.
That should give you this Name: Adobe Cloud Connector - Make Fetch Call. You should now see this:
Next, configure the following:
Change the request protocol from GET to POST
Enter the URL of the Google Cloud Function you created in one of the previous steps which looks like this: https://europe-west1-dazzling-pillar-273812.cloudfunctions.net/vangeluw-event-forwarding
You should now have this. Next, go to Body.
You'll then see this. Click the radio button for JSON.
Configure the Body as follows:
You'll then see this. Click Keep Changes.
You'll then see this. Click Save.
You've now update your existing rule in a Adobe Experience Platform Data Collection Server property. Go to Publishing Flow to publish your changes. Open your Development library Main by clicking Edit as indicated.
Click the Add All Changed Resources button, after which you'll see your Rule and Data Element appear in this library. Next, click Save & Build for Development. Your changes are now being deployed.
After a couple of minutes, you'll see that the deployment is done and ready to be tested.
Go to https://builder.adobedemo.com/projects. After logging in with your Adobe ID, you'll see this. Click your website project to open it.
You can now follow the below flow to access the website. Click Integrations.
On the Integrations page, you need to select the Data Collection property that was created in exercise 0.1.
You'll then see your demo website open up. Select the URL and copy it to your clipboard.
Open a new incognito browser window.
Paste the URL of your demo website, which you copied in the previous step. You'll then be asked to login using your Adobe ID.
Select your account type and complete the login process.
You'll then see your website loaded in an incognito browser window. For every demonstration, you'll need to use a fresh, incognito browser window to load your demo website URL.
When you open up your browser Developer View, you can inspect Network requests as indicated below. When you use the filter interact, you'll see the network requests that are sent by Adobe Experience Platform Data Collection Client to the Adobe Edge.
Switch your view to your Google Cloud Function and go to LOGS. You should now have a view similar to this one, with a number of log entries being shown. Every time you see Function execution started, it means that incoming traffic was received in your Google Cloud Function.
Let's update your function a bit to work with the incoming data, and display the information that was received from Adobe Experience Platform Data Collection Server. Go to SOURCE and click EDIT.
In the next screen, click NEXT.
Update your code like this:
You'll then have this. Click DEPLOY.
After a couple of minutes, your function will be deployed again. Click your function name to open it.
On your demo website, navigate to a product, like for instance DEIRDRE RELAXED-FIT CAPRI.
Switch your view to your Google Cloud Function and go to LOGS. You should now have a view similar to this one, with a number of log entries being shown.
For every page view on your demo website, you should now see a new log entry pop up in your Google Cloud Function's logs, which shows the received information.
You've now successfully sent data that was collected by Adobe Experience Platform Data Collection, in real-time, to a Google Cloud Function endpoint. From there, that data can be used by any Google Cloud Platform application, such as BigQuery for storage and reporting or for Machine Learning use cases.
KEY | VALUE |
---|---|