AMPScript para poner variables en Web Analytics Connector

Código en el Email

<!-- MAIN VARIABLES DO NOT CHANGE START -->    
    <div style="font-size: 0em;">
        %%[
            /* Setting global variables */
            SET @subscriberkey = _subscriberkey
            SET @EmailName = emailname_
            SET @EmailAttributesDE = 'EmailAttributes'
            
            /* Setting Attributes for Email */
            SET @Rows = lookuprows(@EmailAttributesDE,"EmailName", @EmailName)
            SET @RowCount = rowcount(@Rows)
            
            /* Loop for Attributes START */
            IF @RowCount > 0 THEN
            FOR @i = 1 TO @RowCount DO
                SET @Row = row(@Rows, @i)
                SET @Subject1 = field(@Row, 'Subject1')
                SET @Preheader1 = field(@Row, 'Preheader1')
                SET @Subject2 = field(@Row, 'Subject2')
                SET @Preheader2 = field(@Row, 'Preheader2')
                SET @Subject3 = field(@Row, 'Subject3')
                SET @Preheader3 = field(@Row, 'Preheader3')
                SET @UTMSource = field(@Row, 'UTMSource')
                SET @UTMMedium = field(@Row, 'UTMMedium')
                SET @UTMCampaign = field(@Row, 'UTMCampaign')
                SET @UTMTerm = field(@Row, 'UTMTerm')
                SET @UTMID = field(@Row, 'UTMID')
                SET @UTM_Parameters = CONCAT('utm_source=',@UTMSource,'&utm_medium=',@UTMMedium,'&utm_campaign=',@UTMCampaign, '&utm_term=', @UTMTerm)
            NEXT
            ENDIF
            /* Loop for Attributes END */
            /* Checking if Is Test */
            IF @IsTest == True THEN
            SET @Subject = CONCAT('[TEST]: ', @Subject1)
            SET @Preheader = @Preheader1
            ELSE
            /* If it is not test, we check the SL & PH availability */
            IF EMPTY(@Subject2) THEN 
            SET @TotalSubjects = 1
            ELSEIF EMPTY(@Subject3) THEN
            SET @TotalSubjects = 2
            ELSE
            SET @TotalSubjects = 3
            ENDIF
            /* Randomize Subjects and Preheaders if many */
            SET @Random = random(1,@TotalSubjects)
            IF @Random == 1 THEN
            SET @Subject = @Subject1
            SET @Preheader = @Preheader1
            ELSEIF @Random == 2 THEN
            SET @Subject = @Subject2
            SET @Preheader = @Preheader2
            ELSE
            SET @Subject = @Subject3
            SET @Preheader = @Preheader3
            ENDIF /* Random IF END */
            ENDIF /* IsTest IF End */
        ]%%
    </div>
<!-- AMPSCRIPT MAIN VARIABLES DO NOT CHANGE END -->

Variable para Web Analytics Connector

%%=v(@UTM_Parameters)=%%

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *